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!

cumulative-sum
Filter by
Sorted by
Tagged with
0 votes
0 answers
12 views

Sum Total in Recycler view

I have a recycler view with around 15 rows. Each row has some Edit Texts and One Text View at the end. My objective is to calculate Sum of all text views or perform any other operation over it and ...
qais maqbool's user avatar
2 votes
4 answers
62 views

Using Run-Length Encoding and Generating Sums

I have the following run-length encoding data. df1 <- structure(list(lengths = c(2L, 3L, 2L, 1L, 1L, 1L, 1L, 1L, 2L, 1L, 1L, 3L, 1L), values = c(10, 9, NA, 5, 4, 3, NA, 2, NA, 1, 0, NA, 0)), row....
David Moore's user avatar
-1 votes
1 answer
25 views

Google Sheets - different running totals in the same column

I have this sheet with 4 columns: date | name | quantity | running totals In the "name column" are listed different items that are added or subtracted every few days and the respective ...
Alessandro Piccolin's user avatar
1 vote
1 answer
7 views

The Asof join engine output does not match expectations

Why does the cumsum calculation for the TV column restart at the red line, even though the calculations before it are correct?
Claire's user avatar
  • 590
1 vote
2 answers
35 views

Excel Summing a chart Based on Month

Above is a chart I am trying to sum based on the month. Ie I want a running total that I don't have to adjust as each month changes. I know it may look a little strange but the fiscal year for us goes ...
Glen Newell's user avatar
0 votes
1 answer
21 views

How to configure Cumulative Dividend Reinvestment with an initial Value

I have an initial Investment turned into a number of Shares (Ex. $1000 is ~44.4 Shares) My Data.frame() consists of finance yahoo data, being shortened to Date, Avg_Price, and Dividends. My problem is ...
TheNautical_Sailor's user avatar
-1 votes
1 answer
43 views

How to implement recursion in SQL Developer?

I have a table with the following columns: ID, date, amount, amount2 Column amount2 has values only in the first row. I need to recursively calculate each row of column amount2 using values from ...
Lisa's user avatar
  • 3
-1 votes
1 answer
31 views

How to divide rows of data into separate groups based on the value of a column in the data set and calculate the total time of each group?

I have telemetry data that lists the detections of an individual whenever they have been in this zone. For each session, I want to calculate the total time the individual was in that zone. I assume ...
bubblehobby's user avatar
1 vote
1 answer
28 views

How to replace negative values with 0 in Cumulative sum calculation in Tableau?

I have to replace the negative values with 0 in Running sum field. I have created a calculation, like this IF SUM([Sales]) < 0 THEN 0 ELSE RUNNING_SUM(SUM([Sales])) END Table calculation using &...
Radha's user avatar
  • 21
0 votes
2 answers
108 views

Cumulative Sum in ClickHouse

I have clickhouse table with 3 columns: respondent, spot и weight. Data looks like this: resp, spot, weight 1, 10, 100 2, 10, 200 3, 10, 300 1, 10, 100 1, 20, 100 3, 20, 300 4, 20, 400 1, 30, 100 2, ...
Andrei Levin's user avatar
0 votes
1 answer
71 views

Creating a new dataframe column based on values in another column (same row and previous row) as well as the new column in the previous row

I'm looking to create a column in a dataframe based on both another column using two rows and the new column itself. I'm trying to replicate and excel function that creates an ongoing sum of values ...
Jim's user avatar
  • 1
0 votes
1 answer
44 views

Quicksight running percentage total ordered and aggregated by the same field

I have this dataset and need a cumulative percentage column created (see column 4 of image below). (https://i.stack.imgur.com/TFnNn.png) I've looked at a few solutions and found that using runninsum()/...
Jay Dunna's user avatar
0 votes
1 answer
40 views

Display running totals in SSRS in a shape of triangle for Los Development (Loss Triangle) report

I need to make numbers cumulative total in a shape of triangle. Vertical Month-Year is EffectiveDate Horizontal Month-Year is LossDate Should be like this: Using SSRS Expression I am able to get ...
Serdia's user avatar
  • 4,318
0 votes
3 answers
84 views

Calculate running total for net shortage with recursive adjustment and capped surplus

I'm trying to calculate the net shortage on a series of values with the following conditions (shaped into this hypothetical): There is a static run day quota for any given set (production cycle) of ...
jdcook72's user avatar
  • 350
0 votes
1 answer
52 views

Cumulative Total of DAX Measure without Date Filters

I have the following measure in Power BI: _turnover_chart = VAR applNos = CALCULATETABLE( DISTINCT(combined_apps[appl_appl_no]), combined_apps[table_type] = "TRAN" ) RETURN ...
Gray Meiring's user avatar
0 votes
2 answers
60 views

Cumulative amount by report dates

I have two tables sales id colour payment_date amount 1 red 2023-01-04 2 1 green 2023-01-04 5 2 green 2023-01-04 1 2 green 2023-02-04 1 2 green 2023-03-04 1 2 green 2023-04-04 1 report_dates ...
Aleksandr Veselov's user avatar
0 votes
3 answers
70 views

rolling sum with conditions

I have a dataset like: ID DATETIME CODE Value 999 1/2/2024 16:22 TX 100 123 1/2/2024 16:47 IP 100 666 1/2/2024 17:13 IP 85 666 1/2/2024 17:38 IP 100 123 1/2/2024 18:03 ...
Captain Tyler's user avatar
0 votes
0 answers
44 views

Calculate avg acquire price for cumulative balance of each day by SQL using weighted average

enter image description here I have a table like this: each row represents a type of transaction (positive: receive, negative: send). The idea is to calculate the cumulative balance for each day and ...
Leo Nguyen's user avatar
1 vote
1 answer
20 views

Why does matplotlib.pyplot.bar show additional x-values sometimes?

I have written some code that produces a cumulative sum of an array of values. I am trying to plot a bar chart of the values for a statistical comparison test between the orange and blue datasets in ...
D.Cecchi's user avatar
0 votes
1 answer
103 views

Cumulative sum (running total) on a measure in DAX is equal to zero

I'm trying to implement a simple algorithm in PBI, at the end of which I need to calculate a cumulative sum (running total) of a measure (evaluated in memory as I understand it, not in the underlying ...
Saigneur's user avatar
1 vote
1 answer
13 views

DolphinDB: How to set a threshold for cumulative calculation?

I want to create a column “X“ where the values are cumulative sums of an original column “Y“. However, when a value in “X“ reaches a certain threshold (e.g., an absolute value less than 1,000), the ...
winnie's user avatar
  • 283
1 vote
1 answer
63 views

How do I calculate a running total over a specific time period?

I have a data frame with 3 columns, presented below. I would like to calculate potential risk of each material. For each material, the potential risk starts with the date corresponding to the first ...
pyspark-lab's user avatar
0 votes
2 answers
71 views

How to transfer cumulative sum to values in google sheets

I have row with cumulative sum (A1:E1) i.e. 100;300;400;400;500 and need create row (A2:E2) with values:100;200;100;0;100 How to do it with formula in google sheets? my try is: =arrayformula(ADDRESS(...
Paweł Wojewoda's user avatar
0 votes
1 answer
61 views

Performance Issue with CPMpy's Cumulative Constraint

I'm facing a performance issue using cpmpy's cumulative constraint with the ortools solver. Despite a reasonable number of tasks, performance degrades unexpectedly. Is this a bug, or is there a better ...
Kannely's user avatar
0 votes
1 answer
34 views

Cumulative Sum not calculating correctly when segmented by month

I'm working with a dataset in Power BI which contains a table entitled "Transactions" which column showing revenue collected and the date of the transaction. Ultimately, we want to find the ...
AlexN's user avatar
  • 13
1 vote
2 answers
71 views

How do use pivot a table and cumulate them?

I have a dataset which has two destinations and the distance between them. city1 city2 distance 101 102 56 102 103 34 103 104 6 104 105 15 I want to prepare a table which will have the ...
Kishore Kumar's user avatar
1 vote
1 answer
67 views

Power BI Cumulative Sum by Dimension Table

I want to cumulatively sum up cost: I have a cost table And a date table They are connected via the DateKey. I have written the following measure in the Cost Table: Cumulative Total = CALCULATE ( ...
ninelondon's user avatar
0 votes
1 answer
57 views

How can I create a T-SQL query that does a running total with a maximum?

We have an unusual sick time policy where we can't accrue more than 56 hours. I need to write a query to reflect that. This is what I have SELECT t.employeecode, t.LeaveAccrued, PPE, RecordDate, ...
btg's user avatar
  • 29
2 votes
3 answers
83 views

Oracle Cumulative or Incremental subtraction

My Table structure & data- CREATE TABLE T_PTS_TEST ( CITY_ID NUMBER, MNTH DATE, EARNS NUMBER, BURNS NUMBER ); insert into T_PTS_TEST values( ...
satya prakash Panigrahi's user avatar
0 votes
1 answer
54 views

How do i add a column of totals only if the "Name" variable is the same

enter image description here I am trying to keep track of inventory and we use the Frebreeze for example, There are 2 cases of 6 so 12 sub total. Lets say we buy 2 of those, and there are two separate ...
bData's user avatar
  • 1
0 votes
1 answer
149 views

Sum Data Every 12 months ongoing (rolling)

i'm new to google spreadsheet, i'm trying to find a formula / app script from google but kinda hard to find for reference i wish to do the condition where ; Once the data is completed (12 months) it ...
Cyril_Leonel's user avatar
1 vote
0 answers
25 views

PySpark Deciling UDF Not Giving Output & Taking Lot of time to Run

So basically I have created a PySpark function named segmentation that performs cumulative sum calculation, handles outliers, finds the maximum cumulative sum, calculates a decile, and updates a ...
DEVEN MALI's user avatar
0 votes
0 answers
41 views

Create cumulative column in power bi

I should create a cumulative total column on power bi. i have a dataset like this: Date KPI Value 01/02/2022 1 200 01/02/2022 1 250 01/03/2022 1 150 01/01/2022 2 350 01/01/2022 2 450 I created ...
GiorgioP_D's user avatar
1 vote
1 answer
121 views

How to compute Normalized Discounted Gain in R

I am having a hard time understanding how to compute nDCG for my data. I am relatively new to R and I am struggling to translate the formulas to real practice in R. I have a record of 50 columns and I ...
Nampa Gwakondo's user avatar
1 vote
2 answers
69 views

Pandas groupby count unique non cumulative

I have this toy data set df=pd.DataFrame({'user':['John','Steve','Steve','Steve','Jane','Jane','Jane','Jane','Alice','Alice','Alice'], 'days':[1,1,2,3,1,2,3,4,1,2,3]}) yielding user ...
josepmaria's user avatar
0 votes
1 answer
80 views

Cumulative Sum using MySQL in Grafana v6.5.2

I am trying to use a Singlestat panel right now to show the cumulative uph at a specific hour. The desired output is a just 4-digit numeric (ex: 7000). The table is in hourly format, that shows that ...
silver's user avatar
  • 15
0 votes
1 answer
32 views

Cumulative / Running total group by one column

I want to calculate cumulative column. The result i want it's in 2nd table in column "Cumul_result". I have this table : I want to calculate Running total group by article. For exemplace te ...
Juji's user avatar
  • 21
0 votes
1 answer
92 views

Running Total for non date column in PowerBI matrix

I am running into an issue with having no values show up for certain cells in a matrix, when the should be filled in with the cumulative count. I know the issue is related to no underlying values ...
Mark's user avatar
  • 11
0 votes
1 answer
155 views

How do you calculate the total count for all check boxes selected in your word document using the calculate on exit function?

I can't figure out how to get the total boxes selected when I enter them. It allows you to select calculate of exit but I can't figure out the correct code to enter into the properties location of a ...
lynderz's user avatar
0 votes
2 answers
121 views

How do I stop running total from resetting to 0 in void function?

I have an assignment where I'm supposed to make a restaurant menu. The menu must loop until the user enters 4 to get the bill. I'm supposed to use a function to display the menu, and another function ...
Loading Screen's user avatar
0 votes
1 answer
51 views

Cumulative price calculations in PowerBI

I have a dataset of price points per different names and I want to create in PowerBi the cumulative total price for each row for each name. I 've tried creating a measure that calculates the sum of &...
I_m_Possible's user avatar
-1 votes
1 answer
76 views

Running total result set doesn't include rows for records that don't have transactions for a particular month

If i have a result set like this where i want the running total to be present in every ppid. for example plan_id 00-peb17A doesn't have any transactions for ppid 388, so the record is null. I want to ...
Carl Sagan's user avatar
0 votes
0 answers
69 views

Running Totals by Group in a Generative Array and using a Lookup for initial value

Question: Building on from this question on Stack Overflow: Embed SUMIF / Vlookup / Index-Match functions in Recursive Lambda functions in Google Sheets How can I add a running / cumulative total to a ...
Wesley Jeftha's user avatar
1 vote
0 answers
68 views

Calculating rolling sum of inflows with a base limit of 0

I am currently looking to calculate the rolling sum of inflows while ensuring I base my outflows to 0 and never allowing them to get negative. I am attempting to do this in a pyspark dataframe as the ...
akshay's user avatar
  • 11
0 votes
0 answers
31 views

sum amounts with start and enddate by id

I have a dataset for repayment loan amounts it consists of the following, perm_id( firm id), startyear endyear and date as well as repayment for each month. I am trying to accumulate all repayment ...
Seb's user avatar
  • 1
1 vote
1 answer
36 views

Add values of starting row and next row based on a colum from other table

I have two tables. TABLE A Product Plant Stock 11248 ABC12 65 98490 GHI34 54 11248 DEF56 25 TABLE B Product Plant Week Sales Production 11248 ABC12 0 7894 38410 11248 ABC12 ... ... ... 11248 ...
Rocruc's user avatar
  • 35
0 votes
0 answers
33 views

Calculate maximum value of a time based running total measure and filtering time table based on another table

Here is the situation (POWERBI): I have 2 tables: one calendar table named "CALENDAR" and one fact table called "DELIBERE" I have a time based running total measure called "...
V_BI_MAR's user avatar
0 votes
3 answers
70 views

Sum cells in an Excel date table that match given criteria

Year March June Sept December 2002 17.2 23.8 21.3 74.9 2003 23.5 11.5 53.8 29.2 2004 87.1 82.1 48.2 65.7 The Year column is the first day of the year. The quarterly columns are the first day of ...
Stephen's user avatar
  • 475
-1 votes
4 answers
99 views

Time series with running sum of latest orders per tenant

I've a Postgres table like this where a order count for each tenant is inserted when it changes. datetime tenant_id orders 2023-09-15 22:00 tenant3 2 2023-09-16 01:00 tenant1 2 2023-09-16 02:00 ...
dhrm's user avatar
  • 14.7k
1 vote
1 answer
55 views

Why is the cumulative line above the histogram incorrect with `ggplot2`?

I want to overlay the cumulative share of a column with ggplot but the percentages are incorrect Indeed, you can see that the red line starts at 95% whereas the first bin is below at around 82% df <...
Julien's user avatar
  • 1,612

1
2 3 4 5
30