Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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] )
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
24 | |
9 | |
7 | |
6 | |
6 |
User | Count |
---|---|
29 | |
11 | |
11 | |
10 | |
6 |