Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hello,
In Dax, I have this measure:
_AVG 1Y Revenue v2 =
AVERAGEX (
DATESINPERIOD ( Date[Date], LASTDATE ( Date[Date] ), -1, YEAR ),
[Revenue]
)
How can I filter Date[Date] so that the average is calculated based on the working days column Date[isWorkingDay] (0 for weekends, 1 for working days)? putting in mind that DATESINPERIOD doesn't accept virtual tables as its first parameter?
Best regards,
Simon
Solved! Go to Solution.
Try
_AVG 1Y Revenue v2 =
VAR MaxDate =
MAX ( 'Date'[Date] )
VAR LastYear =
DATE ( YEAR ( MaxDate ) - 1, MONTH ( MaxDate ), DAY ( MaxDate ) )
VAR DatesToUse =
CALCULATETABLE (
VALUES ( 'Date'[Date] ),
'Date'[Date] >= LastYear
&& 'Date'[Date] < MaxDate
&& 'Date'[Is Working Day] = 1
)
RETURN
AVERAGEX ( DatesToUse, [Revenue] )
Try
_AVG 1Y Revenue v2 =
VAR MaxDate =
MAX ( 'Date'[Date] )
VAR LastYear =
DATE ( YEAR ( MaxDate ) - 1, MONTH ( MaxDate ), DAY ( MaxDate ) )
VAR DatesToUse =
CALCULATETABLE (
VALUES ( 'Date'[Date] ),
'Date'[Date] >= LastYear
&& 'Date'[Date] < MaxDate
&& 'Date'[Is Working Day] = 1
)
RETURN
AVERAGEX ( DatesToUse, [Revenue] )
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
49 | |
26 | |
20 | |
15 | |
12 |
User | Count |
---|---|
57 | |
49 | |
43 | |
19 | |
18 |