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
Apple08
Helper IV
Helper IV

Rolling 3 months

Hi All

 

I like to add a measure to filter data and graph for rolling 3 months rather than showing the whole year data.  For example, now is Feb 23, I like the data to show the data in Feb 23, Mar 23 and Apr 23, then next month will be Mar 23, Apr 23, May 23.

 

 I have tried the DAX below however it doesn't work.  Please could anyone help me to fix this DAX:

 

Next 3 Months = IF([Date]>=DATE(YEAR(TODAY()),MONTH(TODAY())-1,DAY(TODAY())),"Yes",IF([Date]>=DATE(YEAR(TODAY()&&([Date]<=MONTH(TODAY()+3,DAY(TODAY())),"Yes","No"))

 Many thanks.

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@Apple08 , In case you want 3 month data and month is selected

 

Rolling 3 = CALCULATE(Sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],Min('Date'[Date ]),3,MONTH))

 

Last 3 Months Today =
var _min = eomonth(today(),-1)+1
var _max = eomonth(today(),3)
return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@Apple08 , In case you want 3 month data and month is selected

 

Rolling 3 = CALCULATE(Sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],Min('Date'[Date ]),3,MONTH))

 

Last 3 Months Today =
var _min = eomonth(today(),-1)+1
var _max = eomonth(today(),3)
return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

Thanks very much amitchandak.  The DAX below works perfectly, just a question should it be named as Rolling 3 Months Today rather than Last 3 Months?

 

Last 3 Months Today =
var _min = eomonth(today(),-1)+1
var _max = eomonth(today(),3)
return CALCULATE([Net], FILTER('Date','Date'[Date] >=_min && 'Date'[Date] <= _max))

 

However I am unable to have this work: 

Rolling 3 = CALCULATE(Sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],Min('Date'[Date ]),3,MONTH))

 

I wonder I might have done something wrong.

Thanks very much for your help again.

 

 

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.