Forum Discussion

sagadgreat's avatar
sagadgreat
Helper I
5 years ago
Solved

Constant Average

I need to have an average remain constant for every month on a visual based on only the first 3 months of the year.  Example:   Month 3 mo Avg Net Sales Jan 100 100 Feb 100 100...
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi sagadgreat ,

     

    My sample data is this.

    Month

    Net Sales

    MonthNum

    Customer

    Year

    Jan

    100

    1

    A

    2020

    Feb

    100

    2

    A

    2020

    Mar

    100

    3

    A

    2020

    Apr

    58

    4

    A

    2020

    May

    54

    5

    A

    2020

    Jun

    56

    6

    A

    2020

    Jan

    50

    1

    B

    2020

    Mar

    100

    3

    B

    2020

    Apr

    54

    4

    B

    2020

    May

    58

    5

    B

    2020

    Jun

    56

    6

    B

    2020

    Jan

    100

    1

    A

    2019

    Feb

    50

    2

    A

    2019

    Mar

    100

    3

    A

    2019

    Apr

    58

    4

    A

    2019

    May

    54

    5

    A

    2019

    Jun

    56

    6

    A

    2019

     

    1.Create a measure to get the 3 month average.

    3 mo ave = 
    DIVIDE (
        CALCULATE (
            SUM ( 'Table'[Net Sales] ),
            FILTER (
                ALLEXCEPT ( 'Table', 'Table'[Customer], 'Table'[Year] ),
                [Month] IN { "Jan", "Feb", "Mar" }
            )
        ),
        3
    )

     

    2.Create a measure to get the difference between net sales and the 3 month average.

    difference = [3 mo ave]-MAX('Table'[Net Sales])

     

    3.The result is as follows. Let the filter select a single select.

     

     

    You can check more details from here.

     

     

    Best Regards,

    Stephen Tao

     

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