Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Average Sales by Week - Analytics

Hi I have a line chart with the Year as my legend and the week of the year as my x axis.   I have the sales value each week going across the x axis and all is working well.  When I use the Analyti...
  • v-yingjl's avatar
    5 years ago

    Hi Anonymous ,

    You can create this measure to calculate the average of the each week in each year:

    Average =
    DIVIDE (
        CALCULATE (
            SUM ( 'Table'[Sales] ),
            FILTER (
                ALL ( 'Table' ),
                'Table'[Year]
                    IN DISTINCT ( 'Table'[Year] )
                        && 'Table'[Week] IN DISTINCT ( 'Table'[Week] )
            )
        ),
        CALCULATE (
            COUNT ( 'Table'[Week] ),
            FILTER (
                ALL ( 'Table' ),
                'Table'[Year]
                    IN DISTINCT ( 'Table'[Year] )
                        && 'Table'[Week] IN DISTINCT ( 'Table'[Week] )
            )
        )
    )
    

    Atttached a sample file in the below, hopes it could help.

     

    Best Regards,
    Community Support Team _ Yingjie Li
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.