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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Validate Last 3M DAX query at month level

 Hi All, 
 
Please help me on below DAX query calculate for Last 3M .
 
Last 3M =
VAR MonthsInRange = 3
VAR LastMonthRange =
    CALCULATE (
        MAX ( 'Calendar Month'[Month Yyyymm] ),
        FILTER ( 'Calendar Month', NOT ( ISBLANK ( [Amount] ) ) )
    )
VAR FirstMonthRange =
    --LastMonthRange - MonthsInRange + 1  --202201 - 3 + 1 = 202198 + 1 = 202199
    IF (
        MOD ( LastMonthRange, 100 ) < 3,
        LastMonthRange - 91 + 1 --include year change calc - 94 + 1 <=> - MonthinRange + 1 - 88
        ,
        LastMonthRange - MonthsInRange + 1
    )
VAR Result =
    CALCULATE (
        [Amount],
        REMOVEFILTERS ( 'Calendar Month' ),
        REMOVEFILTERS ( 'Calendar Month Prev' ),
        'Calendar Month'[Month Yyyymm] >= FirstMonthRange
            && 'Calendar Month'[Month Yyyymm] <= LastMonthRange
    )
RETURN
    Result
 
Please let me know if you required more inputs. 
 
Thank You,
 
1 REPLY 1
amitchandak
Super User
Super User

@Anonymous , Create a date with help from a month and year and use TI

 

Rolling 3 = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],MAX('Date'[Date]),-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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors