Forum Discussion

kbarc24's avatar
kbarc24
Regular Visitor
2 years ago
Solved

Average Volume Week YTD by Store

Hi there,  I'm stuck trying to come up with a way to calculate the following: "The average weekly volume (count of rows) since the beginning of the year (YTD) OR since the first date with rows br...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi, kbarc24 

    Based on your information, I create a sample table:

     

    Then create measures and try the following DAX expression:

    Rolling Average Volume A = 
    VAR CurrentWeek = MAX('Table'[Week])
    RETURN
    AVERAGEX(
        FILTER(
            ALL('Table'),
            'Table'[Week] <= CurrentWeek && 'Table'[Store A] <> BLANK()
        ),
        'Table'[Store A]
    )
    Rolling Average Volume B = 
    VAR CurrentWeek = MAX('Table'[Week])
    RETURN
    AVERAGEX(
        FILTER(
            ALL('Table'),
            'Table'[Week] <= CurrentWeek && 'Table'[Store B] <> BLANK()
        ),
        'Table'[Store B]
    )
    Rolling Average Volume C = 
    VAR CurrentWeek = MAX('Table'[Week])
    RETURN
    AVERAGEX(
        FILTER(
            ALL('Table'),
            'Table'[Week] <= CurrentWeek && 'Table'[Store C] <> BLANK()
        ),
        'Table'[Store C]
    )

    Here is my preview:

     

    How to Get Your Question Answered Quickly 

    Best Regards

    Yongkang Hua

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.