Forum Discussion

howe-ch-6541's avatar
howe-ch-6541
Frequent Visitor
1 month ago
Solved

Power BI Date Column Issue

I'm trying to put together a data model that incorporates some rolling averages for 30-90 days. Here is the measure I built: Rolling Average = CALCULATE( AVERAGEX( DATESINPERIOD( ...
  • Nasif_Azam's avatar
    1 month ago

    Hey howe-ch-6541,

    I reproduced it with sample data (a Facts table + a Date Table built the same way, via CALENDAR(MIN/MAX('Facts'[Date])), related 1-to-many to Facts).

     

    Root cause: The date mismatch is not your DAX or model issue. It is caused by having 'Date Table'[Date] and 'Facts'[Date] in the same visual once a measure is added. Time-intelligence measures need to be driven by the Date Table's column only. Adding the fact table's raw date column alongside it breaks the row alignment, which is exactly the repeating/mismatched pattern you saw. 

     

     

    Fix: Drop 'Facts'[Date] from the visual, use only 'Date Table'[Date]:

     

     

    Measure: 
    Rolling Avg 90 (Fixed) =
    CALCULATE(
        AVERAGE('Facts'[Result]),
        DATESINPERIOD('Date Table'[Date], MAX('Date Table'[Date]), -90, DAY)
    )

     

    I attached the PBIX file you can take a look.