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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
HenryJS
Post Prodigy
Post Prodigy

Calculated Column: IF function

Hi all,

 

How do I created a calculated column using DAX for the below:

 

Team = IF 'Username' = 'Adam Thompson' THEN 'London'  

 

etc...

 

I want a new column called team and each team depends on what the username is.

 

 

UserName.PNG

4 REPLIES 4
V-lianl-msft
Community Support
Community Support

 
According to your description, you can use the SWITCH function. But this work may be troublesome. You need to group each user.
 
Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Or perhaps go back to the source of your data and add an extra column in that table.

 

But best avoid writing it in Power Query as it doesn't have an equivalent SWITCH statement.

Anonymous
Not applicable

Hi, 

I would recommend that you create a new table and make a relationship to the orginal table.

Then you dont need to write any dax code.

 

Skärmklipp4.PNGSkärmklipp5.PNG

 

/Adam

amitchandak
Super User
Super User

You can use if like

IF(table[Username] = "Adam Thompson","London" ,"ABC") 

 

But in your case it is better to use switch

https://docs.microsoft.com/en-us/dax/switch-function-dax

https://community.powerbi.com/t5/Report-Server/How-to-use-the-CASE-statement-in-Power-BI/td-p/410864

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges

Connect on Linkedin

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors