I’m working on a dump/damaged report. It’s by item with multiple amount columns. One for sales for the item, and one for the amount dumped or damaged. That part is easy. The tricky part is I only want to show items that have a dump on them. So basically filter the dumped column to exlude all zero amounts.
We sell milk products so dumped refers to items we had to take back because (for example if they are expired).
I did a quick example in excel. Basically I would want to filter the report so it excluded the items in red (ie items that had sales but nothing was dumped).
When I do that I I get zero results. Basically it only is summing up each invoice that has a dump amount on it. When what I want is the total amount of sales of that item number if any of that item number has a dump.
Programically it would be something like
If ITEM has dump qty > 0 then sum sales for that item
slight change of specs. I’ve now got the data being spread accross columns as weeks. So I need it to show all the weeks sales if the total for all the weeks is greater than zero.
We have the formula IF( Qty Dump = 0, BLANK(), SUM( Qty Sold) ) which is worked fine when there was no date/time context.
However, now I’ve added a WEEK context so what that is doing is only showing the sales data for each week IF there is dump for that week. When really what I want to do is show the sales for all the weeks for that item if there is dump on any of the weeks for that item.
I think maybe I can use isfiltered, but it’s not working quite right. I’m just getting the total
Here is the data with no dump filter
Gross Qty Sold no filter = -CALCULATE(SUM('Item Value New'[Invoiced Quantity]),FILTER('Item Value New','Item Value New'[Reason] = "Sales"))
Here I’m just getting the total sales
Gross Qty Sold (w) =
var dumpTotal = if(ISFILTERED(Dates[WeekOfYear])=FALSE(),[Qty Dump],0)
Return
-IF(dumpTotal = 0, BLANK(),CALCULATE(SUM('Item Value New'[Invoiced Quantity]),FILTER('Item Value New','Item Value New'[Reason] = "Sales")))
to clarify you can see on item 01678 you only see the total sales of 15 units, not the 5,6,4 sales per week you see in the first pic
Ok, I think I got it figured out. I used ALL to take to calculate a dump total.
Gross Qty Sold =
var dumptotal = CALCULATE(SUM('Item Value New'[Invoiced Quantity]), ALL(Dates[WeekOfYear]), ('Item Value New'[Reason] = "dump" || 'Item Value New'[Reason] = "damaged"))
return
-IF(dumptotal =0 ,BLANK(), CALCULATE(SUM('Item Value New'[Invoiced Quantity]),FILTER('Item Value New','Item Value New'[Reason] = "Sales")))