Hello Everyone,
I need some help please, I am
Trying to create a moving 5 day average by day for my Power BI report
Currently I have a calendar table as my primary date and that is connected to our revenue table which shows each transaction,
I also have a measure called revenue which is the below DAX Measure
Revenue = SUM(RevenueTable’[JobunadjustedValue]
The measure I have been trying to create is the below but for some reason it works for the first day then the following days it doesn’t calculate properly
5dayMovingValue =
VAR NumOfdays = 5
VAR LastSelectedDate = MAX ( ‘CalendarTable’[Date]
VAR Period =
DATESINPERIOD ( CalendarTable’[Date], LastSelectedDate, -NumOfdays, DAY )
VAR Result =
CALCULATE(
AVERAGEX(
VALUES (CalendarTable’[Date]),
Revenue
),Period
Return Result
My ideal output result is below
Date. 5DayMovingAverage
13/05/2022 £95,000
12/05/2022. £94,765
11/05/2022. £94,500
10/05/2022. £93,100
Thanks