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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
wyanjaspew
Helper I
Helper 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
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.