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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
Gregory-N
Regular Visitor

Dax Switch with multiple answers

Good afternoon,

 

I am trying to build a report for my client to see how many of their clients meet various safety icons.

A supplier can have more than one rating per invoice and it varries per invoice.

Their rating system goes from 1 to 10.

 

They currently fill this in on their accounting system in a single cell with ";" dividing the ratings.

 

So for example, see below screenshot

Safety Rating.JPG

 

 

 

 

 

 

 

I used the Switch function and can manage to find the items listed but the problem is if there is more than one correct answer it doesn't calculate.

 

Safety Icon = SWITCH('Invoices OP'[Safety Icon],"1","Health & Happiness","2","Equity & Local Economy","3","Culture & Community","no")

 

This is a small snippet and doesn't include all 10 icons, only the first 3 for visual purposes.

 

Could someone please asssit me with the above on a way to list all found icons be it one or many in a cell.

 

Looking forward to your assistance fellow BI pioneers 🙂

 

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Gregory-N ,

I create a table to test according to your descriptions.

Please try below steps:

1. below is my test table

Table:

vbinbinyumsft_0-1661842563818.png

2. in power query, split a column by delimiter and split  to row(Split a column of text (Power Query) (microsoft.com))

vbinbinyumsft_1-1661842726757.png

3. load into Power BI and  add a new column with below dax formula

 

Column =
SWITCH (
    'Table'[Safety Icon],
    1, "Health & Happiness",
    2, "Equity & Local Economy",
    3, "Culture & Community",
    "no"
)

 

vbinbinyumsft_2-1661843058346.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @Gregory-N ,

I create a table to test according to your descriptions.

Please try below steps:

1. below is my test table

Table:

vbinbinyumsft_0-1661842563818.png

2. in power query, split a column by delimiter and split  to row(Split a column of text (Power Query) (microsoft.com))

vbinbinyumsft_1-1661842726757.png

3. load into Power BI and  add a new column with below dax formula

 

Column =
SWITCH (
    'Table'[Safety Icon],
    1, "Health & Happiness",
    2, "Equity & Local Economy",
    3, "Culture & Community",
    "no"
)

 

vbinbinyumsft_2-1661843058346.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_ Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you 

PVO3
Impactful Individual
Impactful Individual

Problably the best option is to split up the columns (DAX or PQ) and display icons per category.

Afterwards you could consider creating a measure which concats icons. 

 

If you insist on keeping this column you might want to consider using images instead of icons. You problably have to create all different variants, but then you are able to create URL's.

truptis
Community Champion
Community Champion

Hi @Gregory-N ,

Not sure about what exactly you want to show in the report. But if it's only about showing the attributes then you can try to split your column using a delimiter and then use you SWITCH statement.

 

@Gregory-N -> if this helps you then please hit the thumbs up & mark it as a solution. Thanks.

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.

July 2024 Power BI Update

Power BI Monthly Update - July 2024

Check out the July 2024 Power BI update to learn about new features.

July Newsletter

Fabric Community Update - July 2024

Find out what's new and trending in the Fabric Community.