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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
S_Harmon
New Member

Return value in column if it contains a specific value, if not return value in a different column

Hi,

 

Im trying to create the "New Department" column where it looks for "Machine Shop" or "Charge Shop" in the Supplier column and returns those values if it contains one of those values. If it doesnt, it needs to return the value from the "Department" Column.

 

Can anyone please help?

 

DateNCRNCR TYPEWOPOSUPPLIERPART NUMBERQUANTITYDEPARTMENT New Department
8/1/20241Internal101  ABC 11Assembly Assembly
8/1/20242Internal102 Machine ShopABC 23Assembly Machine Shop
8/10/20243Internal103 Machine ShopABC 17Assembly Machine Shop
8/15/20244Supplier P101Supplier XABC 54Receiving Receiving
8/15/20245Internal104  ABC 28Assembly Assembly
8/15/20246Supplier P102Supplier XABC 45Assembly Assembly
8/15/20247Supplier P103Supplier XABC 23Receiving Receiving
8/20/20248Internal105  ABC 36Assembly Assembly
8/25/20249Internal106  ABC 32Assembly Assembly
8/30/202410Internal107 Charge ShopABC 43Assembly Charge Shop
1 ACCEPTED SOLUTION
rsbin
Super User
Super User

@S_Harmon ,

Please try this as a Calculated Column in DAX:

NewDepartment = SWITCH(
                    TRUE(),
                [Supplier] IN { "Machine Shop", "Charge Shop" }, [Supplier],
                [Department] )

 Else you could do an if function in Power Query as well.

Regards,

View solution in original post

2 REPLIES 2
rsbin
Super User
Super User

@S_Harmon ,

Please try this as a Calculated Column in DAX:

NewDepartment = SWITCH(
                    TRUE(),
                [Supplier] IN { "Machine Shop", "Charge Shop" }, [Supplier],
                [Department] )

 Else you could do an if function in Power Query as well.

Regards,

That worked! Thank you so much! I was way over thinking that for some reason.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.