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
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
Power BI DataViz World Championships

Power BI Dataviz World Championships

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

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.