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
sbutton
Frequent Visitor

How can I classify strings with a large list of conditionals [Power Query]?

I'm attempting to use a list of lists / a table on a separate query to categorize / re-label a column of my dataset using values within the dataset. Essentially need a fix to doing a bunch of if-else statements when trying to classify this outside of a Calculated Column with DAX. I already know how to do that, but since this is part of cleaning the data before it's streamed it doesn't really make sense to keep it out of the query. Would anyone know an effective way to do this?

 

Ex: If [Vendor]=1002 AND [Description].contains("pipe") then [Category] = "Piping, Piping Repairs, " + Description

 

ex.JPG

 

Since there's hundreds of qualifying statements (vendor + code word) attributed to categories I can't just remedy this with a bunch of if statements. Any help would be greatly appreciated!

1 ACCEPTED SOLUTION
v-eqin-msft
Community Support
Community Support

Hi @sbutton ,

 

It depends on what conditions you want to apply.

 

If your multiple conditions are very different ,like 

1.If [Vendor]=1002 AND [Description].contains("pipe") 

2.If [Vendor]=1003 AND [Description].contains("ABC") 

3.If [Vendor]=1004 AND [Description].contains("DEF") 

......

 

I think there will be no better way to achieve that, you will need to use many if ...else .

 

Best Regards,
Eyelyn Qin

View solution in original post

2 REPLIES 2
v-eqin-msft
Community Support
Community Support

Hi @sbutton ,

 

It depends on what conditions you want to apply.

 

If your multiple conditions are very different ,like 

1.If [Vendor]=1002 AND [Description].contains("pipe") 

2.If [Vendor]=1003 AND [Description].contains("ABC") 

3.If [Vendor]=1004 AND [Description].contains("DEF") 

......

 

I think there will be no better way to achieve that, you will need to use many if ...else .

 

Best Regards,
Eyelyn Qin

Anonymous
Not applicable

How many conditions will you have? Have you checked the M of conditional column, then you can edit it in M to for bulky.

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.