Forum Discussion

Gregory-N's avatar
Gregory-N
Regular Visitor
4 years ago
Solved

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

 

 

 

 

 

 

 

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 🙂

 

 

 

  • Anonymous's avatar
    Anonymous
    4 years ago

    Hi Gregory-N ,

    I create a table to test according to your descriptions.

    Please try below steps:

    1. below is my test table

    Table:

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

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

     

    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.

4 Replies

  • truptis's avatar
    truptis
    Icon for Community Champion rankCommunity 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.

  • Anonymous's avatar
    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:

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

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

     

    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.

  • PVO3's avatar
    PVO3
    Icon for Impactful Individual rankImpactful 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.