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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
park
Frequent Visitor

Create custom column based on two other columns

Hello.

 

I would like to add to a formula to a custom column I have written for changing row values based on another column, but I only want to base it off one value.

 

Consider that I have two columns. Company and Type

CompanyTypeNew Column
PublixNFCH
WalmartERCH
PublixDFCH

I currently have this code = if Text.Contains([Company], "Publix", Comparer.OrdinalIgnoreCase) or Text.Contains([Company], "Walmart", Comparer.OrdinalIgnoreCase) then "CH" else [Type]

 

This would change all the Type to CH in a new column based on that company name. 

 

However, for this example. I would like for only the ones that read NF to switch to CH. I want to keep the ones that say ER the same. Besides ER, I also have 2 other values of Type, take example DF FF, I want these to say the same as well. 

 

So basically, I want my formula to do the same thing it is already doing, except ONLY apply to changing the type of NF in a new column to read CH.

 

It would look like:

CompanyTypeNEW Column
PublixNFCH
WalmartERER
PublixDFDF

 

Thank you. 

1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

Use this

= if List.Contains({"Publix","Walmart"},[Company], Comparer.OrdinalIgnoreCase) and [Type]="NF" then "CH" else [Type]

👍 It's been a pleasure to help you | Help Hours: 11 AM to 9 PM (UTC+05:30)

How to get your questions answered quickly -- How to provide sample data

View solution in original post

1 REPLY 1
Vijay_A_Verma
Super User
Super User

Use this

= if List.Contains({"Publix","Walmart"},[Company], Comparer.OrdinalIgnoreCase) and [Type]="NF" then "CH" else [Type]

👍 It's been a pleasure to help you | Help Hours: 11 AM to 9 PM (UTC+05:30)

How to get your questions answered quickly -- How to provide sample data

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.