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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
joew98
Frequent Visitor

Showing multiple slicer values with IF statement

Hi,

 

I have a measure to show multiple values from a single slicer in a card using the CONCATENATEX function. The measure works as expected when it is in a card visual on its own. Below is the measure and the card visual showing two selected values.

 

BOC Selected 2 = CONCATENATEX(BOC, [BOC], " ,")

joew98_0-1698052451835.png

 

However, when I go to make a dynamic measure using the IF statement, the card displays the wrong values if multiple values are selected. Below is the measure used and the card showing multiple values, along with a card with the original measure shown above to show the measure works as expected.

 

Title BOC Label = IF(
    NOT ISBLANK(SELECTEDVALUE(BOC[BOC])),
    [BOC Selected 2],
    "All BOCs")
joew98_0-1698052898171.png

 

Does anybody know why the dynamic measure does not work with an IF statement and multiple selected values? The dynamic measure works if only a single value is selected.

 

Thanks!

 

 

 

1 ACCEPTED SOLUTION

Hi @joew98 ,

Please try:

Title BOC Label = 
VAR _select_count = COUNTROWS(ALLSELECTED('BOC'[BOC]))
VAR _all_count = COUNTROWS(ALL('BOC'[BOC]))
VAR _result = IF(_select_count=_all_count,"All BOCs",[BOC Selected 2])
RETURN
_result

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

View solution in original post

3 REPLIES 3
danextian
Super User
Super User

Hi @joew98 

 

SELECTEDVALUE returns blank in your case because the column  beinig used in the formula is not filtered down to one distinct value only as you selected more than one item.  If your goal is to return the concatenated selected values of BOC column if there are 2 or more selected items, your condition should meet the isblank criterion instead.

=
IF ( ISBLANK ( SELECTEDVALUE ( BOC[BOC] ) ), [BOC Selected 2], "All BOCs" )

If you want to return whatever is/are selected:

=
IF (
    ISBLANK ( SELECTEDVALUE ( BOC[BOC] ) ) || HASONEVALUE ( BOC[BOC] ),
    [BOC Selected 2],
    "All BOCs"
)

 

 










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


Proud to be a Super User!









"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.

Hi @danextian. Thanks for the response. This measure works with showing multiple values but the text "All BOCs" does not show if no value is selected. Do you know why?

 

=
IF (
    ISBLANK ( SELECTEDVALUE ( BOC[BOC] ) ) || HASONEVALUE ( BOC[BOC] ),
    [BOC Selected 2],
    "All BOCs"
)  

 

Hi @joew98 ,

Please try:

Title BOC Label = 
VAR _select_count = COUNTROWS(ALLSELECTED('BOC'[BOC]))
VAR _all_count = COUNTROWS(ALL('BOC'[BOC]))
VAR _result = IF(_select_count=_all_count,"All BOCs",[BOC Selected 2])
RETURN
_result

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.