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

Rolling3months

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

wyanjaspew_0-1754872318630.png


Sample dataset

wyanjaspew_0-1754872657823.png



I’d like the output to look like this.

wyanjaspew_1-1754872354149.png

 



1 ACCEPTED SOLUTION
MasonMA
Resident Rockstar
Resident Rockstar

Hello @wyanjaspew 

 

I would first create one 'DateTable', properly mark it as a Date table in Power BI and use it to filter the fact table by 'one to many' relationship. You can either create Date table in Power Query or with DAX in Power BI. Below is the one with DAX. 

DateTable = 
ADDCOLUMNS(
    CALENDAR(
        DATE(2025,1,1),
        DATE(2025,12,31)
    ),
    "Year", YEAR([Date]),
    "Month", MONTH([Date]),
    "MonthName", FORMAT([Date], "MMMM"),
    "Quarter", "Q" & QUARTER([Date]),
    "YearMonth", FORMAT([Date], "yyyy-MM")
)

MasonMA_0-1754883771441.png

 

After this, use below Measure for 'Rolling_3_Month' calculation (assuming your Total Service ID = DISTINCTCOUNT(test[ServiceID]) ) 

Rolling_3_Months = 
VAR _currentDate = MAX(DateTable[Date])
VAR _rollingPeriod = 
    DATESINPERIOD(
        DateTable[Date],
        _currentDate,
        -3,
        MONTH
    )
VAR _result=
        CALCULATE(
            AVERAGEX(
                VALUES(DateTable[MonthName]), 
                [Total Service ID]
            ),
            _rollingPeriod
        )

RETURN
    IF(
        ISBLANK([Total Service ID]),
        BLANK(),
        _result
        )

With small portion of sample data 

MasonMA_2-1754881096460.png

Hope this helps:)

View solution in original post

5 REPLIES 5
v-saisrao-msft
Community Support
Community Support

Hi @wyanjaspew,

We haven’t heard back from you in a while regarding your issue. let us know if your issue has been resolved or if you still require support.

 

Thank you.

v-saisrao-msft
Community Support
Community Support

Hi @wyanjaspew,

Checking in to see if your issue has been resolved. let us know if you still need any assistance.

 

Thank you.

v-saisrao-msft
Community Support
Community Support

Hi @wyanjaspew,

Have you had a chance to review the solution we shared earlier? If the issue persists, feel free to reply so we can help further.

 

Thank you.

v-saisrao-msft
Community Support
Community Support

Hi @wyanjaspew,

Thank you @MasonMA, for your insights.

I’ve reproduced your issue using a sample dataset and got the below output:

vsaisraomsft_0-1754902318214.png

I’ve also attached the PBIX file for your reference.

Hope this helps

Thank you.

MasonMA
Resident Rockstar
Resident Rockstar

Hello @wyanjaspew 

 

I would first create one 'DateTable', properly mark it as a Date table in Power BI and use it to filter the fact table by 'one to many' relationship. You can either create Date table in Power Query or with DAX in Power BI. Below is the one with DAX. 

DateTable = 
ADDCOLUMNS(
    CALENDAR(
        DATE(2025,1,1),
        DATE(2025,12,31)
    ),
    "Year", YEAR([Date]),
    "Month", MONTH([Date]),
    "MonthName", FORMAT([Date], "MMMM"),
    "Quarter", "Q" & QUARTER([Date]),
    "YearMonth", FORMAT([Date], "yyyy-MM")
)

MasonMA_0-1754883771441.png

 

After this, use below Measure for 'Rolling_3_Month' calculation (assuming your Total Service ID = DISTINCTCOUNT(test[ServiceID]) ) 

Rolling_3_Months = 
VAR _currentDate = MAX(DateTable[Date])
VAR _rollingPeriod = 
    DATESINPERIOD(
        DateTable[Date],
        _currentDate,
        -3,
        MONTH
    )
VAR _result=
        CALCULATE(
            AVERAGEX(
                VALUES(DateTable[MonthName]), 
                [Total Service ID]
            ),
            _rollingPeriod
        )

RETURN
    IF(
        ISBLANK([Total Service ID]),
        BLANK(),
        _result
        )

With small portion of sample data 

MasonMA_2-1754881096460.png

Hope this helps:)

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.

August 2025 community update carousel

Fabric Community Update - August 2025

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