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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Anonymous
Not applicable

dax for cumulative total for last 3months

Hi,

I have a tabular model where i have to create a measure to calculate Running total for last 3 months.The expected output has a grain to be per site per month.The issue is: fact table and month dimension are joined using Report Month field and date dimension has Report Month as FK.This fact table does not have day level data.

How do i acheive this?Attached a sample data

rolling sum.PNG

 

 

 

1 ACCEPTED SOLUTION
v-yuta-msft
Community Support
Community Support

Hi pBI1234,

 

To achieve your requirement, you can create a measure and use DAX like this:

Measure = 
VAR from_ = EOMONTH(MAX(Table1[ReportMo]), -4)
VAR end_  = MAX(Table1[ReportMo])
RETURN
CALCULATE(SUM(Table1[Scrap]), FILTER(ALLEXCEPT(Table1, Table1[Site]), Table1[ReportMo] > from_ && Table1[ReportMo] <= end_))

1.PNG  

PBIX here: https://www.dropbox.com/s/rbo2z3vemawcuvf/dax%20for%20cumulative%20total%20for%20last%203months.pbix...

 

Regards,

Jimmy Tao

Regards,

Jimmy Tao

View solution in original post

2 REPLIES 2
v-yuta-msft
Community Support
Community Support

Hi pBI1234,

 

To achieve your requirement, you can create a measure and use DAX like this:

Measure = 
VAR from_ = EOMONTH(MAX(Table1[ReportMo]), -4)
VAR end_  = MAX(Table1[ReportMo])
RETURN
CALCULATE(SUM(Table1[Scrap]), FILTER(ALLEXCEPT(Table1, Table1[Site]), Table1[ReportMo] > from_ && Table1[ReportMo] <= end_))

1.PNG  

PBIX here: https://www.dropbox.com/s/rbo2z3vemawcuvf/dax%20for%20cumulative%20total%20for%20last%203months.pbix...

 

Regards,

Jimmy Tao

Regards,

Jimmy Tao

Greg_Deckler
Super User
Super User

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, particularly the part about not posting images of data but rather text that can be copied.

 

But, in general you need to use an ALL or ALLEXCEPT in your measure calculation to override the relationship context.


@ 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!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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

Top Solution Authors
Top Kudoed Authors