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

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.

Reply
Anonymous
Not applicable

How to write if then formula with multiple if conditions

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.

2 ACCEPTED SOLUTIONS

@Anonymous You can try with Switch case:

COLUMN = SWITCH(TRUE(),

                     Table[NameColumn]="Kathy","Kat",
                     Table[NameColumn]="Theresa","Kat",

                     Table[NameColumn]="Fred","Kat",

                     "Joe"

                    )

 


  

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

View solution in original post

Anonymous
Not applicable

Yes! Thank you. I believe this is what I needed. 😀

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Thank you for the hand-holding through my first question. I have fixed this.

Tahreem24
Super User
Super User

@Anonymous TRy this DAX:

COLUMN = If((LEFT(Name)=3)="Kat","Kat","Joe")

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
Anonymous
Not applicable

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"

                    )

 


  

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
Anonymous
Not applicable

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.

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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