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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

Filtering a cumulative function

Hi, 

 

I have encountered a problem using my cumulative function. Apparently, the function is taking all the previous sessions. In other words, it is not filtered by my calendar slicer whereas the bar chart is: 

AndrejBI_1-1599487789869.png

In the above picture you can see that it is not starting from a zero nor from the first number in the bar chart. To be specific, it takes all the previous numbers from the data table: 

AndrejBI_2-1599487867102.png

The first data point in the cumulative line should be something around 6k.  This is the cumulative function I used: 

 

 

Total Revenue cumulative = 
    CALCULATE(SUM([Revenue]),
    FILTER(ALL('Calendar'),
    'Calendar'[DateKey]<= MAX('Calendar'[DateKey])))

 

 

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Anonymous , Not very clear. Try like

Total Revenue cumulative =
CALCULATE(SUM([Revenue]),
FILTER(ALLSELECTED('Calendar'),
'Calendar'[DateKey]<= MAX('Calendar'[DateKey])))

View solution in original post

5 REPLIES 5
Greg_Deckler
Super User
Super User

@Anonymous - Without sample data or more information it is hard to say. I would say that it is not correct because you should use ALLSELECTED or ALLEXCEPT except that if you used ALL, then you numbers should be higher than your value for that first day if you were filtering. Any chance you can share the PBIX or more information on what you have as fields/filters in/on that visual? 

 

Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
amitchandak
Super User
Super User

@Anonymous , Not very clear. Try like

Total Revenue cumulative =
CALCULATE(SUM([Revenue]),
FILTER(ALLSELECTED('Calendar'),
'Calendar'[DateKey]<= MAX('Calendar'[DateKey])))

@Anonymous , do you need more help on this

Anonymous
Not applicable

Thanks @amitchandak and @Greg_Deckler, I resolved the issue using ALLSELECTED formula. Nevetheless, I encountered another problem, the revenue is using the same y-axis for bar data (normal) and line data (cumulative). Is there any way to add the second y-axis? 

AndrejBI_0-1599552171319.png

 

@Anonymous - Yes, check under Y-Axis in Formatting pane (paint roller) scroll way, way down, there is an option for Show secondary

Greg_Deckler_0-1599574206622.png

 


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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