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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
newhopepdx
Helper III
Helper III

Multiple conditons in conditional column

The desired outcome is to modify an existing Fund table consisting of the first two columns below by adding the third column.

Funds table:

Fund Name        Class                    Subclass
General Inc        General               General
Misc Inc 1           General               Misc
Misc Inc 2           General               Misc
Misc Inc 3           General               Misc
Other Inc            Whatever           null
Still other Inc     Something         null
etc.

 

Here’s the code I’ve tried for the Subclass column, but it gives all the General class entries a Subclass of “Misc”

 

= Table.AddColumn(#"Sorted Rows", "Funds", each if [Fund Name] = "General Inc" then "General" else if [Class] = "General" then "Misc" else null)

 

Seems like an “AND” is needed in the elseif clause (like: " else if [Class] = "General" AND [Fund Name] <> “General Inc” then "Misc") but I haven’t found the correct syntax.

 

1 ACCEPTED SOLUTION

Thanks.

I tried using an "and" clause but it didn't work... the entries with "General Inc" all ended up as "Misc".  I thought I had the "and" clause wrong, but the problem (aparently) was a space character in the Fund Name field. When I modified the Remove Duplicates to include a trim of the Fund Name, it worked....

= Table.TransformColumns(#"Removed Duplicates",{{"Fund Name", Text.Trim, type text}}) 

View solution in original post

2 REPLIES 2
Ritaf1983
Super User
Super User

Hi @newhopepdx 

If i understood correctly the needed logic than you can use custom column with the syntax :
if [Fund Name]="General Inc" and [Class]="General" then "General"
else if [Fund Name]="Misc Inc" and [Class]="General" then "Misc"
else "null"

Ritaf1983_0-1696694087064.png

if not, you can modify it as you need, this is a good "template".
You can download the file and follow my steps from This link 

If this post helps, then please consider Accepting it as the solution to help the other members find it more quickly

Regards,
Rita Fainshtein | Microsoft MVP
https://www.linkedin.com/in/rita-fainshtein/
Blog : https://www.madeiradata.com/profile/ritaf/profile

Thanks.

I tried using an "and" clause but it didn't work... the entries with "General Inc" all ended up as "Misc".  I thought I had the "and" clause wrong, but the problem (aparently) was a space character in the Fund Name field. When I modified the Remove Duplicates to include a trim of the Fund Name, it worked....

= Table.TransformColumns(#"Removed Duplicates",{{"Fund Name", Text.Trim, type text}}) 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.