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
brahweiz
Regular Visitor

Cumulative sum with time-intelligent slicer

Hi,
I'm new to Power BI, and I'm working on this measure to show cumulative sum on specific time period.
The case and what I want:
I have one Calendar table [DateKey], and main data table [Data], they have relationship based on column date.
Show a visual of line & clustered column chart and a time slicer, in which show cumulative sum of revenue based on the slicer.
For eg: I have revenue table for January, I put out the DateKey[Month] column as slicer, when I choose January, the visual would show the cumulative sum of Revenue in July (from 1st to 31st July)
When I choose August, the visual would show cumulative sum Revenue in August (from 1st to 31st August)
What I did and try: I used the following DAX
Cumulative Sum Rev = CALCULATE(
SUM(Data[Revenue]),
FILTER(
ALL(Data),
Data[Date]<=MAX(Data[Date])
)
)
Actual outcome: It did create a cumulative sum line, but it was fine for July. If I choose August in slicer, it would be in continue from July. What I expected is the cumulative sum will begin from August, not from July.
I tried another solution, which is using ALLEXCEPT instead of ALL, but it does seems not working (you can see my measures in the pbix files already have it, but to filter another column [Lead_type], which works perfectly fine for another slicer)
Please help to show me where I was wrong.
Here is the link to my pbix file, it include what my visual would be and my measure:
https://1drv.ms/u/s!As4H0zrXywmbhaVFDprZ6RJmFUMbbg?e=l4Wxe5

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

Use this measure

Cumulative sum 1 = CALCULATE(SUM(Data[Revenue]),DATESMTD(DateKey[Date]))
Hope this helps.
Untitled.png

Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

2 REPLIES 2
Ashish_Mathur
Super User
Super User

Hi,

Use this measure

Cumulative sum 1 = CALCULATE(SUM(Data[Revenue]),DATESMTD(DateKey[Date]))
Hope this helps.
Untitled.png

Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
lbendlin
Super User
Super User

Any particular reason for not using the built-in functions like TOTALMTD() ? Of course there are many ways to write that measure, but maybe start with the standard functions.  Power BI offers "Quick Measures" that cover a wide range of frequently used patterns.

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.