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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
Anonymous
Not applicable

Rolling 3 months Average

Hi everyone.

 

I have encounter an issue on my report and need your help.

I need a calculation of Trend and it's definition is:

Average of the last 3 months of the month selected.

 

If my slicer is selected for example:

Jan/2021 the Average should be from Nov/2020 + Dec/2020 + Jan/2021(Blue selection)

Feb/2021 the Average should be from Dec/2020 + Jan/2021 + Feb/2021 (Orange selection)

 

Salgas_0-1616706709221.png

 

My slicer of the month comes from my COD_Calendar table

Salgas_2-1616706841270.png

 

But my data table has data from 01/2020 till 02/2021

 

Can anyone please help me with these

4 REPLIES 4
ERD
Community Champion
Community Champion

Hello @Anonymous ,

To get the average value for the last 3 months (starting from the chosen one in slicer), you'll need to have a proper calendar table (including dates for 2020 and 2021 upon the example) and the next measure:

EDITED upon the next comment

 

 

Trend = 
IF(HASONEVALUE(Calendar[Date]),
    CALCULATE(
        AVERAGE(DataTable[Value]),
        DATESINPERIOD(
            Calendar[Date],
            SELECTEDVALUE(Calendar[Date]),
            -3, MONTH)
    ), 
    AVERAGE(DataTable[Value]))

 

 

 

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

Anonymous
Not applicable

Hi @ERD 

 

Your usage of the time-intel functions is incorrect and will often yield wrong values. Please refer to this guide to understand when you can correctly use them: DATESINPERIOD – DAX Guide. A hint would be: You cannot use time-intel functions with fact tables. You have to have a proper date/calendar table (dimension) to be safe.

ERD
Community Champion
Community Champion

Thanks for the hint! Edited previous advise.

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

Check out my latest demo report in the data story gallery.

Stand with Ukraine!


Here are official ways you can support Ukraine financially (accounts with multiple currencies):
1) Support the Armed Forces of Ukraine: https://bank.gov.ua/ua/about/support-the-armed-forces
2) Come Back Alive foundation: https://www.comebackalive.in.ua/

Thank you!

amitchandak
Super User
Super User

@Anonymous , Try a measure like this with help from date table

 

Rolling 3 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date ],eomonth(MAX('Date'[Date ]),-1),-3,MONTH))

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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