Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello,
I have a PowerBI dashboard which has a date table connected to a table of student applications. I also have a slicer of academic years.
I would like to be able to capture the multiple selections made on the slicer to be used in further DAX expressions in a CALCULATE statement.
For example: (psuedo code)
VAR selected_years = SELECTEDVALUE('Date'[Academic Years])
VAR calc =
CALCULATE(COUNT('Student Applications'[Id])
FILTER(
'Date',
'Date'[Academic Years] IN selected_years
)
)
RETURN calc
Solved! Go to Solution.
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
User | Count |
---|---|
22 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
26 | |
13 | |
11 | |
9 | |
6 |