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
RDillon-2025
New Member

IF OR Formula in Power Query for each row

Hi There,

 

I need to replicate below screen shot formula "OBSOLETE QTY" in Power Query. But I'm stuck because my power query is not calculating the 3 columns ....

 

I tried in power query as: 

if [Sales Status] ="S6" or [Sales Status] = "S5", then [#"Consolidated Qty Stock 7-12"] + [#"Consolidated Qty Stock 12+"] + [Consolidated Qty Inactive]

else 0

 

 

 

OBS QTY Formula .png

1 ACCEPTED SOLUTION
BA_Pete
Super User
Super User

Hi @RDillon-2025 ,

 

When you say it's not calculating the three columns, what exactly do you mean? Are you getting an error, just a null value or what?

Based on what I can see, there may be a couple of issues:

 

1) You have a comma in your code, which will give you an error.

2) If your table in Power Query actually has nulls instead of zeroes, the addition you're doing will evaluate to null.

 

Try using this code instead:

if [Sales Status] = "S6" or [Sales Status] = "S5"
then List.Sum({[#"Consolidated Qty Stock 7-12"], [#"Consolidated Qty Stock 12+"], [#"Consolidated Qty Inactive"]})
else 0

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

3 REPLIES 3
BA_Pete
Super User
Super User

Hi @RDillon-2025 ,

 

When you say it's not calculating the three columns, what exactly do you mean? Are you getting an error, just a null value or what?

Based on what I can see, there may be a couple of issues:

 

1) You have a comma in your code, which will give you an error.

2) If your table in Power Query actually has nulls instead of zeroes, the addition you're doing will evaluate to null.

 

Try using this code instead:

if [Sales Status] = "S6" or [Sales Status] = "S5"
then List.Sum({[#"Consolidated Qty Stock 7-12"], [#"Consolidated Qty Stock 12+"], [#"Consolidated Qty Inactive"]})
else 0

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Pete Thank you !!!!!!!!! it works perfectly well OMG I missed out the list.sum as initially I added and then I removed the reason I was getting zero results  it thank you heaps I'll note for all future!!!! I have one more will post a different query.

 

No problem, happy to help.
Don't forget to give a thumbs-up on any posts that have helped you ‌‌👍

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors