Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hello everyone.
I would like to calculate sales for all years prior to the selected year in a filter with the year field from the calendar table.(including the year itself).
If I write the measure in this way it works (for example for all sales prior 2023)
Rolling All 1 =
CALCULATE (
SUM(Sales[Amount[) ,
FILTER (
Sales,
Sales[Year] <= 2022))
But if i Try to dynamically pass year selected from the user by the filter, it does not work and show me only 2022 sales
Rolling All 2=
var YearSelected= SELECTEDVALUE(Calendar[Year] )
RETURN
CALCULATE (
SUM(Sales[Amount[) ,
FILTER (
Sales,
Sales[Year] <= YearSelected))
What is the way to pass a value selected by a filter to a measure? (in this case filter linked to the calendar and specifically to the year)
Thank you very much
Solved! Go to Solution.
Sorry, I solved with this code:
Sorry, I solved with this code:
Try
Rolling All 2 =
VAR YearSelected =
SELECTEDVALUE ( Calendar[Year] )
RETURN
CALCULATE (
SUM ( Sales[Amount] ),
'Calendar'[Year] <= YearSelected,
REMOVEFILTERS ( 'Calendar' )
)
User | Count |
---|---|
58 | |
21 | |
18 | |
16 | |
13 |
User | Count |
---|---|
85 | |
54 | |
39 | |
21 | |
18 |