Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

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
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.