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

Rolling 12 month Sum for completed months

Good morning,

 

Looking for a rolling 12 month and/or a rolling 365 days of sales, however, if the month is not complete then default to previous months rolling 12 month value.  I've tried several methods on this forum, but nothing seems to be producing the desired result.  Not sure if anyone has any tips to help solve this.  Thank you!!!

 

Desired result in yellowDesired result in yellow

1 ACCEPTED SOLUTION

@Jkaelin,

Create the following measures and check if you get expected result.

last month of last year = CALCULATE([Rolling 12M Sales],FILTER(ALL('Master_Calendar'),'Master_Calendar'[Year]=YEAR(TODAY())-1 && 'Master_Calendar'[MonthOfYear]=12))
Expected result = IF(YEAR(TODAY())>MAX('Master_Calendar'[Year])&&TODAY()>EOMONTH(MAX('Master_Calendar'[Date]),0),[Rolling 12M Sales],[last month of last year])

1.JPG

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
Greg_Deckler
Super User
Super User

Can you post your formula? I'm guessing it can be fixed with an IF statement and a CALCULATE with a MAX filter but can't know for sure.


@ 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...

@Greg_Deckler

 

Hey Smoupre! This is one of my formula's.  I've tried a variety of IF, THEN statements to no avail.  

 

 

Rolling 12M Sales :=
CALCULATE (
    [Total Revenue],
    DATESBETWEEN (
        'Master_Calendar'[Date],
        NEXTDAY ( SAMEPERIODLASTYEAR ( LASTDATE ( 'Master_Calendar'[Date] ) ) ),
        LASTDATE ( 'Master_Calendar'[Date] )
    )

 

This formula was posted by @Vvelarde in another related thread, but it would error out on me.  

 

ValueCalc = if(TODAY()>=EOMONTH(VALUES(Table1[DateRef]);0);EXPRTRUE;EXPRFALSE)

 

This seems like it should be easy to do but then I can't do it, makes me feel like I have no understanding of Row/Filter context.  😞

 

So, is the main table you are dealing with 'Master_Calendar' or some other table? And if some other table, what is filtering dates from master_calendar, a relationship?


@ 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...

@Greg_Deckler

 

The main table is my factSales table.  My main calendar table is 'Master_Calendar'.  Master Calendar is a one-to-many to the factSales table.  Any ideas on a good approach?  

 

Kindly - James

@Jkaelin,

Create the following measures and check if you get expected result.

last month of last year = CALCULATE([Rolling 12M Sales],FILTER(ALL('Master_Calendar'),'Master_Calendar'[Year]=YEAR(TODAY())-1 && 'Master_Calendar'[MonthOfYear]=12))
Expected result = IF(YEAR(TODAY())>MAX('Master_Calendar'[Year])&&TODAY()>EOMONTH(MAX('Master_Calendar'[Date]),0),[Rolling 12M Sales],[last month of last year])

1.JPG

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

@v-yuezhe-msft

 

Thank you for your help.  Sorry for delay in responding, I been under the weather.  The measures you created work and appears to do the trick.  Thank you!

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.