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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
wyanjaspew
Advocate I
Advocate I

Rolling values for 3 months

Hi Guys,

Could you help me configure this? I'm trying to display the rolling 3-month period using the following DAX code.

wyanjaspew_0-1754619624349.png


I’d like the output to look like this.

wyanjaspew_1-1754619718452.png

 



1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

One of ways is to use WINDOW DAX Function in calculated table formula.

Please check the below picture and the attached pbix file.

 

WINDOW function (DAX) - DAX | Microsoft Learn

 

 

Jihwan_Kim_0-1754620441254.png

 

 

Calculated Column expected result = 
VAR _t =
    WINDOW (
        -2,
        REL,
        0,
        REL,
        test,
        ORDERBY ( test[date], ASC ),
        ,
        ,
        MATCHBY ( test[date] )
    )
VAR _condition =
    COUNTROWS ( _t ) = 3
RETURN
    IF ( _condition, AVERAGEX ( _t, test[value] ) )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

One of ways is to use WINDOW DAX Function in calculated table formula.

Please check the below picture and the attached pbix file.

 

WINDOW function (DAX) - DAX | Microsoft Learn

 

 

Jihwan_Kim_0-1754620441254.png

 

 

Calculated Column expected result = 
VAR _t =
    WINDOW (
        -2,
        REL,
        0,
        REL,
        test,
        ORDERBY ( test[date], ASC ),
        ,
        ,
        MATCHBY ( test[date] )
    )
VAR _condition =
    COUNTROWS ( _t ) = 3
RETURN
    IF ( _condition, AVERAGEX ( _t, test[value] ) )

 


If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Click here to visit my LinkedIn page

Click here to schedule a short Teams meeting to discuss your question.

Thanks! I'm trying to incorporate the code into a measure within my actual dataset, but it doesn't seem to be functioning properly.

wyanjaspew_0-1754629152309.png

 

Actual dataset

wyanjaspew_1-1754629206094.png

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.