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
y5famfnatudu
Resolver I
Resolver I

Calculate AVG 3M, based on Working Days

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

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

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] )

View solution in original post

2 REPLIES 2
johnt75
Super User
Super User

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] )

Thank you so much @johnt75 

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

Find out what's new and trending in the Fabric community.

July PBI25 Carousel

Power BI Monthly Update - July 2025

Check out the July 2025 Power BI update to learn about new features.