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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
Anonymous
Not applicable

SumProduct with IF Condition

I have multiple PO numbers in one column and the corresponding Order Quantity and Weight of each item in that PO. Now to calculate the total weight of the PO, I need to multiply Order Quantity*Weight for each item and sum it up if there are multiple items in the PO. In excel, Im using a sumproduct formula with If condition. for eg .

SUMPRODUCT(IF($F$2:$F$29190=F2,$S$2:$S$29190),IF($F$2:$F$29190=F2,$T$2:$T$29190))

F Column = PO Number

S Column = Order Quantity

T Column = Weight

 

How do I replicate this in Power BI?

1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @Anonymous 

 

Download PBIX file with example shown below

 

This is my dummy data

ord1.png

 

In Power Query you can multiply the weight by the quantity to give a new column called (e.g.) Qty Weight.

 

ord2.png

 

Then group by the PO Number column (right click on the column header and click Group By)

ord0.png

 

Then select sum for the aggregation on the newly created Qty Weight column (or whatever you want to call the column)

ord3.png

 

Final result 

ord4.png

 

Regards

 

Phil

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @PhilipTreacy : The results are as expected, Thank You! Is there a way I can have the remaining columns (i.e Qty, Weight) also in the final table/view ?

Hi @Anonymous 

 

How exactly do you want the final table to look? 

 

Using my source data, would you end up with 6 rows in which case, how do I show the weight and qty for each item in the order?

 

Or if you want 22 rows then the Order Weight is duplicated for each row of the respective order.

 

Regards

 

Phil

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Anonymous
Not applicable

Hi @PhilipTreacy : I would want the Order Weight to be duplicated for each row for the respective PO Number. For eg. in your database : For PO Number 1, 58 is the order weight which will be duplicated for all the rows for that PO ( 4 rows in case of PO number 1)

 

StoryTeller12_0-1669366184443.png

 

Hi @Anonymous 

 

Download sample PBIX file

 

OK you just need to do a table join so that the result of the grouping is merged with the original data - basically your merging the table with itself.

 

= Table.NestedJoin(#"Changed Type", {"PO Number"}, #"Grouped Rows", {"PO Number"}, "Order Weight", JoinKind.LeftOuter)

 

mrg1.png

 

 

Then expand the table in the column to give the Order Weight

 

mrg2.png

 

mrg4.png

 

Regards

 

Phil

 

 

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


PhilipTreacy
Super User
Super User

Hi @Anonymous 

 

Download PBIX file with example shown below

 

This is my dummy data

ord1.png

 

In Power Query you can multiply the weight by the quantity to give a new column called (e.g.) Qty Weight.

 

ord2.png

 

Then group by the PO Number column (right click on the column header and click Group By)

ord0.png

 

Then select sum for the aggregation on the newly created Qty Weight column (or whatever you want to call the column)

ord3.png

 

Final result 

ord4.png

 

Regards

 

Phil

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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