Forum Discussion

ebrownretail's avatar
ebrownretail
Resolver I
2 years ago
Solved

Average sales for upcomign weeks

Hi! I am new to Power BI and trying to build this to help manage inventory. We are a seasonal item, so we have very large humps in our sales progression during certain seasons. Due to this, i need t...
  • ebrownretail's avatar
    ebrownretail
    2 years ago

    Thank you for the reply! i was wondering if there is a way to do this without designating specific weeks? The week numbers will obviously change as the year progresses, and i dont want to have to edit the measure everytime.

     

    Is it possible to have this do all week numbers, and then i can narrow down with a slicer to the specific week numbers i want?

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi ebrownretail ,

     

    I suggest you to try New Parameter feature to create a weeknum slicer.

    For reference: Use parameters to visualize variables - Power BI | Microsoft Learn

    Then update your measure as below.

    AverageWeek =
    VAR _SELECTWEEK =
        SELETEDVALUE ( 'WeekNum'[Week] )
    VAR _Avg1 =
        CALCULATE (
            AVERAGEX (
                VALUES ( DateTable[Year] ),
                CALCULATE ( [TotalSales], DateTable[Week] = _SELECTWEEK + 1 )
            ),
            ALL ( DateTable[Year] )
        )
    VAR _Avg2 =
        CALCULATE (
            AVERAGEX (
                VALUES ( DateTable[Year] ),
                CALCULATE ( [TotalSales], DateTable[Week] = _SELECTWEEK + 2 )
            ),
            ALL ( DateTable[Year] )
        )
    RETURN
        _Avg1 + _Avg2

     

    Best Regards,
    Rico Zhou

     

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