Questions tagged [cumulative-sum]

For questions regarding implementations or algorithms for calculating cumulative sums (also known as running totals). Always add the tag for the language/platform!

A cumulative sum (also known as a running total or partial sum) refers to the concept of maintaining only a single value (the sum), which is updated each time a new value is added to the sequence.

1433 questions
-1
votes
1 answer

How to get the cumulative sum of children up its parents?

So I have written a query to get the cumulative sum of children but I think partition sum has error as its totalling for the parent that is not part of the children. My fiddle is http://sqlfiddle.com/#!15/88828/1 I have dont a running total but…
JyotiChhetri
  • 289
  • 1
  • 7
  • 21
-1
votes
1 answer

Attempting to get monthly totals for subqueries

I'm trying to get monthly subtotals, breaking down into specific product types. This worked for one month, but when I try to do a number of months I get repeating totals inside the subqueries. Tricky part is each Opp Status needs to join a central…
-1
votes
1 answer

How to calculate running total per month?

I have a table in PostgreSQL: date value '2020-06-02' 150 '2020-06-03' 7891 '2020-07-02' 392 ... ... I need to get running total of numbers in value column for each date in table. The sum of value in running total has to be…
rsx
  • 33
  • 4
-1
votes
1 answer

calculate cumulative sum until the selected date (represented by filter drop down list)

I'm traying to calculate cumulative sum for a Project until date selected in the filter. My filter date is a drop down list and it shows like this for example: July 2020 Aug 2020 ..... I have 2 tables: factworkinghours table and dimdates…
Hadar
  • 1
-1
votes
1 answer

Cumulative Sum with lower bound BigQuery Standard SQL

I'm fairly new to BigQuery and Standard SQL and am trying to calculate a cumulative sum, where the resulting column should not go below 0 and keep on calculating the cumulative sum from there. This question is similiar, but uses SQL Server. Let's…
-1
votes
1 answer

substract two ECDF time series

Hi I have a ECDF plot by seaborn which is the following. I can obtain this by doing sns.ecdfplot(data=df2, x='time', hue='seg_oper', stat='count'). My dataframe is very simple: In [174]: df2 Out[174]: time seg_oper 265 …
Lucas Aimaretto
  • 1,399
  • 1
  • 22
  • 34
-1
votes
1 answer

Stepwise summing from adjacent cell

Summing down the way in excel. Im trying to calculate the total along a path in stepwise pieces, for example for each blank row I want the total from the left cell and add it to the total overall. column 14 row 1 should be 3925.923, C14 R2…
-1
votes
1 answer

How do you cumulatively aggregate string in pandas?

I have a column that contains strings. Rm 0 Rwws,xxALd 1 Ras,yySAw 2 Bdbbd1dd I want to cumulatively aggregate the string through the y-axis. This is the desired output. …
Borut Flis
  • 15,715
  • 30
  • 92
  • 119
-1
votes
3 answers

Cumulative sum of a column

I have a table that has the below data. COUNTRY LEVEL NUM_OF_DUPLICATES US 9 6 US 8 24 US 7 12 US 6 20 US 5 39 US 4 81 US 3 80 US 2 …
Vinay
  • 3
  • 2
-1
votes
2 answers

Rolling calculations with lag and ifelse

I'm trying to calculate the cumulative sum of a column in my data frame, but I only want it to be done based on a condition. I am very new to R and trying to convert this spss code below in R to achieve the dataframe below with a new column called…
Sarah
  • 11
  • 1
-1
votes
3 answers

Running count SQL server

Can someone please help me in counting the rows in SQL Server Id Date Trend A 15-1-20 Uptrend A 14-1-20 Uptrend A 13-1-20 Uptrend A 12-1-20 NULL A 11-1-20 Uptrend A 10-1-20 Uptrend A 09-1-20 NULL Expected result Id Date Trend Counttrend A…
ajay tilak
  • 13
  • 2
-1
votes
1 answer

Python_Cumulative sum based on two conditions

I'm trying to compute the cumulative sum in python based on a two different conditions. As you can see in the attached image, Calculation column would take the same value as the Number column as long as the Cat1 and Cat2 column doesn't change. Once…
GusRo
  • 7
  • 4
-1
votes
3 answers

How to get cumulative sum in SQL Server (Z=Z+A+B-C)

I want to create cumulative sum in table ( Commul_table) in SQL such as Z=Z+ (A+B-C )
Ali Jamal
  • 3
  • 2
-1
votes
1 answer

Cumulative sum within group till threshold is reached

I have the following exemplary data frame: df <- as.data.frame(cbind(Month <- c("Jun", "Jul", "Aug", "Oct", "Jun", "Aug", "Feb"),ID <- c(1,1,1,2,2,2,2), No_ind <- c(8,5,2,15,10,9,2))) names(df) <- c('month', 'ID', 'No_ind') I have already sorted…
ABiologist
  • 43
  • 6
-1
votes
2 answers

Is there any way to calculate running total with condition in Redshift?

I'm running a volume availability model for a package center at Redshift. In this table column B shows arrived volume at every hour. The shift starts at 1700 and ends at midnight. During that time they can process 50K packages every hour(column C).I…