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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
LearnPowerBIAS
Frequent Visitor

DAX in SWITCH

Hi Friends, 

Need urgent help.

I have a column in DB with numbers, 

Names
1
2
3
4
5

 

But in UI those numbers are linked to Names likes 

1 -AA

2 - BB

3 - CC

4 - DD

5 - EE

 I need to show the names in Table visual not the numbers; So in this case i wrote SWITCH function DAX but the result is

NamesNames
1AA
2,3 
3CC
4DD
4,5 

How to show if they select multipe values in Names coulmns . Please help. TIA

DAX I used:

Names = SWITCH(Names, 1, "AA", 2,"BB", 3, "CC", 4, "DD", 5, "EE")

How to modify this. ?

5 REPLIES 5
tamerj1
Super User
Super User

Hi @LearnPowerBIAS 

can you be more specific about the switch statement. Is it applied to a calculated column or measure? Which column/table is involved in this formula? Whi column/table is used in the slicer? How does the report look like?

I created a calculated coulmn using this formula Names = SWITCH(Table[Names], 1, "AA", 2,"BB", 3, "CC", 4, "DD", 5, "EE")

Hi @LearnPowerBIAS,

 

Here is the correct version of this SWITCH statement...😎

Names = SWITCH(
TRUE(),
Table[Names] = 1, "AA",
Table[Names] = 2, "BB",
Table[Names] = 3, "CC",
Table[Names] = 4, "DD",
Table[Names] = 5, "EE"
)

 

I am only ammending the DAX I don't know the specifics of your problem, could you give an example table and then the result you'd expect? Or does this solve your problem or give you a better clue on how to solve it? 😊

 

@LearnPowerBIAS 

What about the other questions? How about sharing some screenshots?

LearnPowerBIAS_0-1677269841205.png

Here for 2,3 also I need to return the values. But now its coming as empty . This is a TAble visual. 

 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

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

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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