cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
Morkil
Helper I
Helper I

Handle multiple slicer selections in a visual card with "Multiple options selected"

Hi,

 

I am creating a visual card that interacts with a slicer, whereby if a user selects one option from the slicer the option will display in a separate visual card. If a user does not select an option the visual card will display "No option selected". Finally, if a user selects multiple options from the slicer the visual card will display the selected options concantenated or if over 3 options are selected the card shall return: "Multiple options selected"

 

Note: All slicer options come from the same column within the table (Region).

 

Currently I have got this:

 

ConcatTest =

VAR _Counter = COUNTROWS(VALUES('Business Unit'[Region]))

VAR _Concat = CONCATENATEX(VALUES('Business Unit'[Region]), 'Business Unit'[Region], ", ")

RETURN
IF(ISBLANK(SELECTEDVALUE('Business Unit'[Region])), "Please select a region",
IF(
_Counter=1, SELECTEDVALUE('Business Unit'[Region]),
IF(
_Counter>1, _Concat,
IF(
_Counter>2, "Multiple regions selected"))))
 
 
Is there a means of using if else statements in DAX?
 
Any help is appreciated.
 
Thank you.
1 ACCEPTED SOLUTION
ValtteriN
Super User
Super User

Hi,

Here is one way to do this kind of state checking:

Slicer state =
SWITCH(TRUE(),
HASONEFILTER('Table (7)'[Attribute]), "One value selected",
ISFILTERED('Table (7)'[Attribute]), "Multiple values selected",
"No selection")



Here the SWITCH + TRUE works as iterative if structure, HASONEFILTER check for case where only one filter is applied and ISFILTERED checks for multiple filters. Lastly else for no filters.


ValtteriN_0-1663052003700.pngValtteriN_1-1663052016700.pngValtteriN_2-1663052030684.png

 

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/




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

Proud to be a Super User!




View solution in original post

4 REPLIES 4
ValtteriN
Super User
Super User

Hi,

Here is one way to do this kind of state checking:

Slicer state =
SWITCH(TRUE(),
HASONEFILTER('Table (7)'[Attribute]), "One value selected",
ISFILTERED('Table (7)'[Attribute]), "Multiple values selected",
"No selection")



Here the SWITCH + TRUE works as iterative if structure, HASONEFILTER check for case where only one filter is applied and ISFILTERED checks for multiple filters. Lastly else for no filters.


ValtteriN_0-1663052003700.pngValtteriN_1-1663052016700.pngValtteriN_2-1663052030684.png

 

I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!

My LinkedIn: https://www.linkedin.com/in/n%C3%A4ttiahov-00001/




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

Proud to be a Super User!




Hi,
Appreciate your response and it has helped very much.
Currently I can handle whether multiple regions or one single region/s are selected, but when no regions are selected the card returns the "multiple regions" strings.


This is the dax:

Testing =

VAR _Counter = COUNTROWS(VALUES('Business Unit'[Region]))
VAR _Concat = CONCATENATEX(VALUES('Business Unit'[Region]), 'Business Unit'[Region], ", ")
RETURN

SWITCH(TRUE(),
HASONEFILTER('Business Unit'[Region]), SELECTEDVALUE('Business Unit'[Region]),
_Counter=2, _Concat,
_Counter>2, "Multiple regions selected",
_Counter=1, "Please select a region")

It seems as if it won't accept the _Counter=1 condition

Any help is appreciated

Hi,

The last part of SWITCH argument is [else] like this:

SWITCH(<expression>, <value>, <result>[, <value>, <result>]…[, <else>])

Because of this you don't need the counter = 1 part of the dax since If a slicer doesn't have one or multiple values its state is logically no filters. This way we can use the else part of SWITCH. 





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

Proud to be a Super User!




Hi,

I need your help,

 

I have a situation here where I need to show multiple values selected from multiple sicers in a card visual.

multiple values of same slicer should be seperated by ","and multiple values from multiple slicers should be seperated by "|". 

when no values selected from any of the slicers , it should show "Not Selected"

for example, if I select 2017 and 2018 from Year slicer,

result is : 2017,2018   (here "|" is not expecting after the result)

if I select HYD and BZA  from LocID slicer and  2021,2022 from year slicer and Azure-C,Azure-F from CourseID,

result is: HYD,BZA | 2021,2022 |Azure-C,Azure-F

If I select no values from three slicers,

Result is: Not Selected

 

Thanks in advance...

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors