Forum Discussion
Average sales for upcomign weeks
- 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?
- Anonymous2 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 + _Avg2Best Regards,
Rico ZhouIf this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
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?
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.