Forum Discussion
A ? for a Report: How to Subtract Returned Items Quantities
- 8 years ago
kcantor
I created a conditional field as you told me called "Quantity"and it worked thanks. The returns now shows negative quantity.
let
Source = OData.Feed("------"),
#"Post Purchases_table" = Source{[Name="Post Purchases",Signature="table"]}[Data],
#"Added Conditional Column" = Table.AddColumn(#"Post Purchases_table", "Quantity", each if [Type] = "Return" then [ReceiptQty]*-1 else [ReceiptQty])
in
#"Added Conditional Column"THEN. I tried to create an aditional column called "Qty" for the report to sumarize the Quantities so it could automatically substract those Returns with negative numbers BUT The designer shows the error in the picture below.
How do I create that new Qty column to make it SUM those positive and negative Quantities?
In Query Editor create a conditional column for the if statement of Type.
If [Type}="Return" then [ReceiptQty]*-1 else [ReceiptQty]
Then you can group and the returns will be subtracted.
- hidalgo8 years agoRegular Visitor
kcantor
I created a conditional field as you told me called "Quantity"and it worked thanks. The returns now shows negative quantity.
let
Source = OData.Feed("------"),
#"Post Purchases_table" = Source{[Name="Post Purchases",Signature="table"]}[Data],
#"Added Conditional Column" = Table.AddColumn(#"Post Purchases_table", "Quantity", each if [Type] = "Return" then [ReceiptQty]*-1 else [ReceiptQty])
in
#"Added Conditional Column"THEN. I tried to create an aditional column called "Qty" for the report to sumarize the Quantities so it could automatically substract those Returns with negative numbers BUT The designer shows the error in the picture below.
How do I create that new Qty column to make it SUM those positive and negative Quantities?
- kcantor8 years ago
Community Champion
In your M code it does not appear that the conditional column for Quantity had the data type changed. By default, powerquery uses data type any. You will need to go into Query Editor and change the data type of your new conditional column to a number and then your calculation will work properly.