Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
Hi,
I am trying to write a DAX statement (my very first one) that does something like this - (just an example for ease of understanding)
If First Name is Kathy, Nickname is Kat
If First Name is Katherine, Nickname is Kat
If FIrst Name is Katrina, Nickname is Kat
Otherwise Nickname is Joe
I know how to do this:
Nickname = if('Users'[First Name]="Kathy", "Kat", "Joe")
However, I don't know how to get the additional name options in there that would also equal Kat.
Any help would be profoundly appreciated.
Solved! Go to Solution.
@Anonymous You can try with Switch case:
COLUMN = SWITCH(TRUE(),
Table[NameColumn]="Kathy","Kat",
Table[NameColumn]="Theresa","Kat",
Table[NameColumn]="Fred","Kat",
"Joe"
)
Yes! Thank you. I believe this is what I needed. 😀
Thank you for the hand-holding through my first question. I have fixed this.
@Anonymous TRy this DAX:
COLUMN = If((LEFT(Name)=3)="Kat","Kat","Joe")
Hi Tahreem24, thank you for taking the time to answer. I really appreciate it. I was using that scenario as an example and I see I have mistakenly expressed my issue incorrectly because of the example I used. The point I meant to make was that I have three different if statements, that don't necessarily start with the same 3 letters. I meant to simplify the example, but only complicated it. My question is more like this:
If First Name is Kathy, Nickname is Kat
If First Name is Theresa, Nickname is Kat
If First Name is Fred, Nickname is Kat
Otherwise Nickname is Joe.
Otherwise Nickname is Joe
@Anonymous You can try with Switch case:
COLUMN = SWITCH(TRUE(),
Table[NameColumn]="Kathy","Kat",
Table[NameColumn]="Theresa","Kat",
Table[NameColumn]="Fred","Kat",
"Joe"
)
Yes! Thank you. I believe this is what I needed. 😀
@Anonymous I am glad that your issue has been solved. But you mistakenly marked your reply as a solution. Kindly properly mark right reply as a solution which will help others also.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
115 | |
100 | |
88 | |
68 | |
61 |
User | Count |
---|---|
152 | |
120 | |
102 | |
87 | |
68 |