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.
Hi Power BI community
I have a filter that can choose between three options called A,B and C
When I write this DAX code
Status = IF(SelectedValue(table[status]) = "A",1,0)
Then I get 1 if A is the selected value, but if A and B are selected or all options are selected then I get 0
I need to get the value 1 as long as A is one of the selected options regardless og what else I have selected.
All help is greatly appreciated.
Solved! Go to Solution.
SELECTEDVALUE by default always returns blank if more than one values are visible (two or emore selected, or none selected which is equivalent to all). To check whether A is in the selected values. try
-- Returns 1 if "A" is present in visible rows of 'table'[status] , otherwise returns 0
IF ( "A" IN VALUES ( 'table'[status] ), 1, 0 )
This will, of course, naturally return 0 if A is not among the selected values.
SELECTEDVALUE by default always returns blank if more than one values are visible (two or emore selected, or none selected which is equivalent to all). To check whether A is in the selected values. try
-- Returns 1 if "A" is present in visible rows of 'table'[status] , otherwise returns 0
IF ( "A" IN VALUES ( 'table'[status] ), 1, 0 )
This will, of course, naturally return 0 if A is not among the selected values.
Thanks @danextian it works as a charm and solved my problem write a way.
with a very short and elegant line of DAX.
Hey, @ThomasWeppler
selectedvalue always return blank if there's multuple values selected, however, you can modify the behavior with optional parameter:
IF(SELECTEDVALUE(table[status], "A") = "A",1,0)
@vojtechsima thanks for the answer, but if I just use
IF(SELECTEDVALUE(table[status], "A") = "A",1,0)
and the selected selectedvalues are "B" and "C" than I will still get a false positive.
@ThomasWeppler all right, get it now,
then use CONCATENATEX
IF(
CONTAINSSTRING( CONCATENATEX(VALUES(_table[status]), _table[status],""), "A"),
1,
0
)
but @danextian 's solution is better, cleaner and efficient.
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
71 | |
70 | |
38 | |
26 | |
26 |
User | Count |
---|---|
100 | |
87 | |
45 | |
43 | |
35 |