Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

How to calculate “Cumulative”

Hi everyone

I've a calculated column named "WeekNum" that returns the number of week of a date and a measure named "Total Selloutsthat calculates total sellouts for each week. 

The formula of the measure is the following:  
 
Total SellOuts =  

var x = CALCULATE(SUM('MyTable'[Qt_1]),FILTER('MyTable', 'MyTable'[Date].[Year] = YEAR(TODAY()))) 

var x = CALCULATE(SUM('MyTable'[Qt_2]),FILTER('MyTable', 'MyTable'[Date].[Year] = YEAR(TODAY()))) 

return x - y 
 
This is my current situation: 
 
WeekNum  (calculated column)                  Total Sellouts (Measure)   

1 

33 

2 

16 

 3 

7 

 4 

4 

 5 

8 

 6 

4 

 7 

16 

 8 

12 

 
 

need to obtain the "Cumulative" column:
 
Weeks (calculated column)      Total SellOuts (Measure)                   Cumulative (Measure) 

1 

33 

33 

2 

16 

49 

3 

7 

56 

4 

4 

60 

5 

8 

68 

6 

4 

72 

7 

16 

88 

8 

12 

100 

  

Cumulative:

33 = 33

49 = 33 + 16

56 = 33 + 16 + 7

60 = 33 + 16 + 7 + 4

..

 

Thanks  

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi there, I solved my problem.

 

Cumulativo =
SUMX (FILTER (ALLSELECTED ( 'MyTable'[WeeksNumber] ), 'MyTable'[WeeksNumber] <= MAX('MyTable'[WeeksNumber])), [SellOuts])
 
rickymazz_2-1616493858003.png

 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi there, I solved my problem.

 

Cumulativo =
SUMX (FILTER (ALLSELECTED ( 'MyTable'[WeeksNumber] ), 'MyTable'[WeeksNumber] <= MAX('MyTable'[WeeksNumber])), [SellOuts])
 
rickymazz_2-1616493858003.png

 

Krutigawale33
Responsive Resident
Responsive Resident

Hello @Anonymous ,

 

Try with the measure,

unning Total COLUMN =
CALCULATE (
SUM ( 'MyTable'[Total Sellouts] ),
ALL ( 'MyTable' ),
( 'MyTable'[Date] ) <= EARLIER ( 'MyTable'[Date] )
)

Anonymous
Not applicable

Hi @Krutigawale33
I can't use CALCULATE(SUM('MyTable'[Total Sellouts]) because Total Sellouts is already a measure. 

Total SellOuts =  

var x = CALCULATE(SUM('MyTable'[Qt_1]),FILTER('MyTable', 'MyTable'[Date].[Year] = YEAR(TODAY()))) 

var x = CALCULATE(SUM('MyTable'[Qt_2]),FILTER('MyTable', 'MyTable'[Date].[Year] = YEAR(TODAY()))) 

return x - y 

Hello @Anonymous ,

 

Can you able to provide sample data with date column.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors