Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
ThomasWeppler
Impactful Individual
Impactful Individual

Selectedvalue() doesn't work when multiple options are selected

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.

 

1 ACCEPTED SOLUTION
danextian
Super User
Super User

hi @ThomasWeppler 

 

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.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

View solution in original post

5 REPLIES 5
danextian
Super User
Super User

hi @ThomasWeppler 

 

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.





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

Thanks @danextian it works as a charm and solved my problem write a way.

with a very short and elegant line of DAX.

vojtechsima
Super User
Super User

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)





Any kudos or recognition appreciated. To learn more on the topic, check out my blog and follow me on LinkedIn.

@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
)

 

vojtechsima_0-1742209482768.png

 

but @danextian 's solution is better, cleaner and efficient.






Any kudos or recognition appreciated. To learn more on the topic, check out my blog and follow me on LinkedIn.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

FabCon and SQLCon Highlights Carousel

FabCon &SQLCon Highlights

Experience the highlights from FabCon & SQLCon, available live and on-demand starting April 14th.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.