Forum Discussion
Cumulative sum from different categories in same plot/table
Dear all,
we are struggling for finding the best method to apply cumulative sum from two different categories and putting into the same table and plot.
As Main source, here is the table:
the table is split into two different category: 2025 and 2024.
The desired answer is:
Column Day has been created using this DAX in the Calendar table:
| date | Score |
| 01-01-2025 | 5 |
| 01-01-2025 | 8 |
| 02-01-2025 | 4 |
| 03-01-2025 | 3 |
| 04-01-2025 | 5 |
| 04-01-2025 | 6 |
| 05-01-2025 | 4 |
| 02-01-2024 | 4 |
| 02-01-2024 | 8 |
| 02-01-2024 | 1 |
| 03-01-2024 | 1 |
| 04-01-2024 | 8 |
| 05-01-2024 | 3 |
Best regards,
Cornelis
CornelisV Find steps below:
Created a table using your data:
for year 2024 cumulative sum will start as 13 not 19 as 8+1+4 = 13
1. Create new column as a Year and Day.
2. Create cummulative Column with below dax code:
Column Running Total =CALCULATE(Sum('Table (4)'[Score]),'Table (4)'[Date] <= EARLIER('Table (4)'[Date]),'Table (4)'[Year] = EARLIER('Table (4)'[Year]),ALL('Table (4)'))Result :let me know if this helps
6 Replies
- mh2587Super User
Cumulative Score = // Try this one might help you VAR SelectedYear = SELECTEDVALUE('Calendar'[Year]) VAR CurrentDay = MAX('Calendar'[DayOfYear]) RETURN CALCULATE( SUM('Source'[Score]), FILTER( ALL('Calendar'), 'Calendar'[Year] = SelectedYear && 'Calendar'[DayOfYear] <= CurrentDay ) ) - Sachin001Frequent Visitor
CornelisV Find steps below:
Created a table using your data:
for year 2024 cumulative sum will start as 13 not 19 as 8+1+4 = 13
1. Create new column as a Year and Day.
2. Create cummulative Column with below dax code:
Column Running Total =CALCULATE(Sum('Table (4)'[Score]),'Table (4)'[Date] <= EARLIER('Table (4)'[Date]),'Table (4)'[Year] = EARLIER('Table (4)'[Year]),ALL('Table (4)'))Result :let me know if this helps