Don't miss your chance to take the Fabric Data Engineer (DP-600) exam for FREE! Find out how by attending the DP-600 session on April 23rd (pacific time), live or on-demand.
Learn moreNext up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now
Hi all! I'm wondering if I could write a better IF statement for my problem. I have a "person" column, and I need to create a "location" column based on person's name. There are a lot of names (over 30) and lots of locations (10). Instead of writing endless nested IF statement below, is there an easier way to do this?
Just an example of my current statement: if(OR(person_name="person1",person_name="person2"),"location1", IF(OR(person_name="person3" ...
Table1:
Person_Name Location
| person1 | location1 |
| person2 | location1 |
| person3 | location1 |
| person4 | location1 |
| person5 | location1 |
| person6 | location1 |
| person7 | location1 |
| person8 | location1 |
| person9 | location1 |
| person10 | location2 |
| person11 | location2 |
| person12 | location2 |
| person13 | location2 |
| person14 | location2 |
| person15 | location2 |
| person16 | location2 |
| person17 | location2 |
| person18 | location2 |
| person19 | location2 |
| person20 | location3 |
| person21 | location3 |
| person22 | location3 |
| person23 | location3 |
| … | … |
Thank you in advance!
Solved! Go to Solution.
depends what you mean by endless for which solution is better.
This one has a few nested ifs but not nearly as many:
depends what you mean by endless for which solution is better.
This one has a few nested ifs but not nearly as many:
Hi again! I used SWITCH statement in Excel data model and it worked. But when I used the exact same statement (copy and paste) in SSAS, it gave me an error that the syntax for 'IN' is incorrect.
I did some google search and a few people had the same issue but no solution. Do you happen to know why? Thank you!
Thank you so much! SWITCH works perfectly.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.
Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.
| User | Count |
|---|---|
| 9 | |
| 6 | |
| 3 | |
| 2 | |
| 2 |
| User | Count |
|---|---|
| 21 | |
| 14 | |
| 9 | |
| 5 | |
| 5 |