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

if when column in power query

Hi all,

 

I am struggling to get a if when statement to work as a calculated column in power query. the logic I am trying to create is:

 

if [sales] > 0

where [region] = AMER

and [returns] < 1 where [type] IN 1,2,3,4,5

Then 1 else " "

 

I am not fully sure if this is even possible in PQ, any suggestions on how to get this logic to work in PQ? 

 

Thank you!

1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Hi @Anonymous ,

 

Try to create a custom column with Power query:

if [Region]= "a" and [Returns] <1 and [Sales]>0 and List.Contains({1,2,3},[Type])
then 1 else ""

Vlianlmsft_0-1650007784948.png

 


Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

5 REPLIES 5
V-lianl-msft
Community Support
Community Support

Hi @Anonymous ,

 

Try to create a custom column with Power query:

if [Region]= "a" and [Returns] <1 and [Sales]>0 and List.Contains({1,2,3},[Type])
then 1 else ""

Vlianlmsft_0-1650007784948.png

 


Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

@V-lianl-msft I keep getting this error when using this logic: [Expression.Error] We cannot convert the value null to type Logical.

 

how fo you handle this? 

Anonymous
Not applicable

also thank you @V-lianl-msft 

rajkmr106
New Member

This is defently  possible in power query, You need to filter the value based on required value and also need to mentioned the condition for it.

Anonymous
Not applicable

@rajkmr106  what would the correct logic look like? 

if [sales] > 0

filter [region] = AMER

and [returns] < 1 filter [type] IN 1,2,3,4,5

Then 1 else " " ?

 

 

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Kudoed Authors