Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

4 Week Average with a Day Filter

Hi all, I am hoping to create a 4 Week average which can be changed based off a day slicer. For example if the Slicer is on a Monday then it would show average for the last 4 mondays etc. I have h...
  • Jihwan_Kim's avatar
    Jihwan_Kim
    2 years ago

    Hi,

    Thank you for your message.

    Please check the below and the attached pbix file if it suits your requirement.

     

    4 Week Average = 
    VAR _fourweekstable =
        WINDOW (
            -3,
            REL,
            0,
            REL,
            SUMMARIZE ( ALL ( 'PpOH Request from Harold' ), 'Calendar'[Week Ending Date] ),
            ORDERBY ( 'Calendar'[Week Ending Date], ASC )
        )
    VAR _condition =
        COUNTROWS ( _fourweekstable ) = 4
    RETURN
        IF (
            _condition,
            AVERAGEX (
                _fourweekstable,
                CALCULATE ( SUM ( 'PpOH Request from Harold'[PatronHours] ) )
            )
        )