Forum Discussion
Using multiple values from slicer in CALCULATE DAX expression
- 4 years ago
VAR selected_years = VALUES('Date'[Academic Years])
VAR calc =
CALCULATE(COUNT('Student Applications'[Id])FILTER(
'Date',
'Date'[Academic Years] IN selected_years
)
)
RETURN calc
If you do SELECTEDVALUE it will only return that value if there is one and for multiple choices will default to blank.
In general , if you just want to capture the years selcted then you don't need to do anything cause they are already taken by default in the filter context on measures that acts on related table.
So, for instance, this would have given you the same result:
COUNT('Student Applications'[Id])
btw, also this would give you the same result per yoor pseudo code:VAR selected_years = VALUES('Date'[Academic Years])
VAR calc =
CALCULATE(
COUNT('Student Applications'[Id]),selected_years
)
RETURN calc
VAR selected_years = VALUES('Date'[Academic Years])
VAR calc =
CALCULATE(COUNT('Student Applications'[Id])
FILTER(
'Date',
'Date'[Academic Years] IN selected_years
)
)
RETURN calc
If you do SELECTEDVALUE it will only return that value if there is one and for multiple choices will default to blank.
In general , if you just want to capture the years selcted then you don't need to do anything cause they are already taken by default in the filter context on measures that acts on related table.
So, for instance, this would have given you the same result:
COUNT('Student Applications'[Id])
btw, also this would give you the same result per yoor pseudo code:
VAR selected_years = VALUES('Date'[Academic Years])
VAR calc =
CALCULATE(
COUNT('Student Applications'[Id]),
selected_years
)
RETURN calc