Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Get input from slicer

hello everyone!

Im tyring to show on a chart sales of each week for 13 weeks. I have table that table contain years and weeks nums , sales. The challlenging part for me I have to get input from user and the chart has to show me the picked weeks and previous 12 weeks. For example if user pick the 11th week of 2024 the chart show me the 52,53 this comes from last year and 1,2,3 ....11 weeks.Im using slicer but its not working Can anyone help me ?

The DAX code of measure:

sales =
VAR __WEEK = SELECTEDVALUE(ShelfAvailability[Week],WEEKNUM(TODAY()))
VAR __13WEEK = __WEEK - 12
VAR __YEAR = SELECTEDVALUE(ShelfAvailability[Year],YEAR(TODAY()))
VAR __RESULT = CALCULATE(SUM(ShelfAvailability[SalesOfWeek]),
                            FILTER(ShelfAvailability,
                                   ShelfAvailability[Week] >= __13WEEK &&
                                   ShelfAvailability[Week] <= __WEEK &&
                                   ShelfAvailability[Year] = __YEAR),ALL(ShelfAvailability))
RETURN
__RESULT

1 Reply