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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

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 like below.

wyanjaspew_0-1754631659414.png

 

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

wyanjaspew_2-1754631796732.png

 

Actual dataset

wyanjaspew_3-1754631832629.png

 

 




9 REPLIES 9
v-sshirivolu
Community Support
Community Support

Hi @wyanjaspew ,

I would also take a moment to thank @rohit1991 , for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.
 

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions

rohit1991
Super User
Super User

Hi @wyanjaspew 

 

1. Create a proper Date table

In Modeling >> New table:

 

Date =
ADDCOLUMNS (
   CALENDAR ( MIN ( FactSales[Date] ), MAX ( FactSales[Date] ) ),
   "Year", YEAR ( [Date] ),
   "Month", FORMAT ( [Date], "MMM" ),
   "YearMonth", FORMAT ( [Date], "YYYY-MM" )
)
  • Mark as date table (Modeling >> Mark as date table >> select [Date]).
  • Create a relationship: Date[Date] >> FactSales[Date] (single direction).

2. Base measure

Amount =
SUM ( FactSales[Amount] )

 

3. Rolling 3-month sum (includes current month + prior 2)

Rolling 3M (Sum) =
CALCULATE (
   [Amount],
   DATESINPERIOD ( 'Date'[Date], MAX ( 'Date'[Date] ), -3, MONTH )
)

 

 4. Rolling 3-month average

Rolling 3M (Avg)=
VAR Sum3M =
   CALCULATE (
       [Amount],
       DATESINPERIOD ( 'Date'[Date], MAX ( 'Date'[Date] ), -3, MONTH )
   )
VAR MonthsPresent =
   CALCULATE (
       DISTINCTCOUNT ( 'Date'[YearMonth] ),
       DATESINPERIOD ( 'Date'[Date], MAX ( 'Date'[Date] ), -3, MONTH )
   )
RETURN
DIVIDE ( Sum3M, MonthsPresent )

 

5. Build the visual

  • Use a Table or Matrix.
  • Put Date[YearMonth] (or Date[Date] set to Month), then add:
    • [Amount]
    • Rolling 3M (Sum) (and/or Rolling 3M (Avg))

You should see the DAX measure match the Expected_Rolling3M_Sum in the Excel.

rohit1991_0-1754634569977.jpeg

 


Did it work? ✔ Give a Kudo • Mark as Solution – help others too!

When I apply this code, it only display the same numbers (sum) of my serviceid's

wyanjaspew_0-1754663540260.png

 

Hi @wyanjaspew  ,

Seeing repeated values usually suggests that your rolling measure isn't getting the right filter context from the model. Here are some things to check:

Date Table

Make sure you have a proper Date table created with your DAX.

Set it as a Date table in your model.

Confirm it covers your entire data range.

Model Relationship

In Model view, check for a single-directional relationship from Date[Date] to FactSales[Date].

Visual Context

Use a table or matrix that includes serviceid with your rolling measures.

Verify the service-level filter is applied so the measure recalculates for each service.

Quick Test

Add a slicer for serviceid to see if the rolling measure updates.

If it doesn't, there's likely a relationship or context issue.

With these steps, your rolling 3-month DAX should provide different values for each serviceid as expected.



Hi @wyanjaspew ,

I hope the above details help you fix the issue. If you still have any questions or need more help, feel free to reach out. We’re always here to support you

 

Hi @wyanjaspew ,

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.

Hi @wyanjaspew 

Could you please check this:
In Model view, create a relationship from Date Table[Date] (1) to Fact Sales[Date] (*)


Did it work? ✔ Give a Kudo • Mark as Solution – help others too!
MohamedFowzan1
Responsive Resident
Responsive Resident

Hi @wyanjaspew 

 

Could you check if this works:

Rolling 3 Month Total =
CALCULATE(
    SUM(FactTable[ValueColumn]),
    DATESINPERIOD(
        'DateTable'[Date],
        MAX('DateTable'[Date]),  
        -3,
        MONTH
    )
)

When I apply this code, it only display the same numbers (sum) of my serviceid's

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.