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
williamadams12
Resolver I
Resolver I

Cumulative SUM based on different dates in two different measures?

I'm struggling to create a single measure cumulative sum that's based on an aggregate of two different measures each with a different set of dates. 

 

Has anyone ever tried this before?

 

 

5 REPLIES 5
v-xicai
Community Support
Community Support

Hi   @williamadams12 ,

 

Does that make sense? If so, kindly mark the proper reply as a solution to help others having the similar issue and close the case. If not, let me know and I'll try to help you further.

 

Best regards

Amy

Apologies for the delayed response, I was out for a few weeks with a broken clavicle and broken arm, so I'm just getting back to typing reasonably well 🙂 

 

This looks helpful so far, but I'm still having trouble with the date filters per each measure. 

 

Essentially I have an aggregated total by month for two different measures that total out to an entire year. 

 

Actuals= Jan -> June

Projections = July ->Dec 

 

I want to add these two measures together for a cumulative sum I need to add to an area chart comparison.

v-xicai
Community Support
Community Support

Hi @williamadams12 ,

 

You may create measure like DAX below.

 

Cumulative SUM=

Var _MinDate= [Measure StartDate]

Var _MaxDate= [Measure EndDate]

Return

CALCULATE(SUM(Table1[Value]),FILTER(ALLSELECTED(Table1), Table1[Date] >=_MinDate&& Table1[Date] <=_MaxDate ))

 

If I misunderstood it, could you please share your sample data and desired output screenshots for further analysis? You can also upload sample pbix to OneDrive and post the link here. Do mask sensitive data before uploading.

 

Please read this post to get your answer quickly: How to Get Your Question Answered Quickly.

 

Best Regards,

Amy 

 

Community Support Team _ Amy

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@williamadams12 , you can join both dates with same date table use userelation .

example


Cumm Sales = CALCULATE(SUM(Sales[Sales Amount]),filter(date,date[date] <=maxx(date,date[date])),userelation(Date[date],Sales[order Date]))
+ CALCULATE(SUM(Sales[Sales Amount]),filter(date,date[date] <=maxx(date,date[date])),userelation(Date[date],Sales[delivery Date]))

 

Refer example here to https://community.powerbi.com/t5/Community-Blog/Decoding-Direct-Query-in-Power-BI-Part-1-Time-Intell...

kentyler
Solution Sage
Solution Sage

If you use VAR statements it should be straightforward

 

Grand Total = 
VAR total1 = [total1 measure]

VAR total2 = [total2 measure]
RETURN total1 + total2

 

This assumes all the work is being done in the sub measures, including the date filtering for different dates. Since you're filtering for different date ranges you will probably need to use CALCULATE and change the filter context for each of the sub measures. Let us know if you need help with the DAX for the sub measures... please post some small sample data.





Did this post answer your question? Mark it as a solution so others can find it!

Help when you know. Ask when you don't!




Join the conversation at We Talk BI find out more about me at Slow BI


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.