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
Anonymous
Not applicable

Help with correcting conditional column in Power Query

Hi

 

Can someone help me correct this:

 

= Table.AddColumn(#"Changed Type1", "Charge", if [Freight_Kind] = "ABC" and [Category] = "BBC" or "BBD" then 10.5 else 0)

 

error Im getting is:

Expression.Error: There is an unknown identifier. Did you use the [field] shorthand for a _[field] outside of an 'each' expression?

 

Thanks so much!

 

1 ACCEPTED SOLUTION

Then you should provide a sample...

or...

 

= Table.AddColumn(#"Changed Type1", "Charge", each if [Freight_Kind]="ABC" and ([Category]="BBC"or [Category]="BBD") then 10.5 else 0)

 

And you can play with parenthesis...

View solution in original post

4 REPLIES 4
Jakinta
Solution Sage
Solution Sage

= Table.AddColumn(#"Changed Type1", "Charge", if [Freight_Kind] = "ABC" and [Category] = "BBC" or [Category]="BBD" then 10.5 else 0)

Anonymous
Not applicable

Thanks for your quick response but Im still getting the same error?

 

Then you should provide a sample...

or...

 

= Table.AddColumn(#"Changed Type1", "Charge", each if [Freight_Kind]="ABC" and ([Category]="BBC"or [Category]="BBD") then 10.5 else 0)

 

And you can play with parenthesis...

Anonymous
Not applicable

Thats done it, thanks so much!

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.