Filter 0-values in PivotTable - excel

I have the following Excel spreadsheet:
A B C
Product Sent Quantity Returned Quantity
1 Product A 500 0
2 Product A 400 300
3 Product A 600 400
4 Product B 250 0
5 Product B 300 150
6 Product C 700 0
The table shows the sales (Column B) an returns (Column C) of a product.
I created a Pivot-Table out of the data above which leads to the follwoing result:
Sum of Sent Quantity Sum of Returned Quantity
Product A 1.500 700
Product B 550 150
Product C 700 0
Now I use the Returned Quantity as a Report Filter.
I set "150" as the filter criteria and I get the following result:
Sum of Sent Quantity Sum of Returned Quantity
Product B 550 150
So far everything works fine.
Now I change the filter from "150" to "0" and I get the following result:
Sum of Sent Quantity Sum of Returned Quantity
Product A 500 0
Product B 250 0
Product C 750 0
However, my target result is:
Sum of Sent Quantity Sum of Returned Quantity
Product C 700 0
What do I have to change to reach my target result?

So, I have entered your data in "Sheet1" like this:
Then, in "Sheet2" I made folowing table:
Which is your pivot table. But cells are defined with formulas:
B2: =SUMIF(Sheet1!$A$2:$A$7,Sheet2!A2,Sheet1!$B$2:$B$7)
C2: =SUMIF(Sheet1!$A$2:$A$7,Sheet2!A2,Sheet1!$C$2:$C$7)
The rest is just matter of draging it down (it will adjust automatically, as you know). Now, just lock first row and then you can apply any filters to it.

Here's a slightly different way to do it, which only requires one table, and allows you to filter and display values in your pivot table:
A B C D
1 Product Sent Quantity Returned Quantity Sum of Returned Quantity
2 Product A 500 0 700
3 Product A 400 300 700
4 Product A 600 400 700
5 Product B 250 0 150
6 Product B 300 150 150
7 Product C 700 0 0
The formula in cell D2 is =SUMIF($A:$A,$A2,C:C) Copy this formula down the column.
Then set Sum of Returned Quantity as your filter, and it should work correctly. Additional columns may be added for additional filters and you can hide the subtotal column(s) if you wish.

Related

Different count results in PivotTable based on 0-values in database

I have the following Excel spreadsheet:
A B C
Sent Quantity Returned Products
1 Product A 500 0
2 Product A 400 300
3 Product A 600 400
4 Product B 250 0
5 Product B 300 150
6 Product C 700 0
The table shows the sent quantity (Column B) and returned quantity (Column C) of each sale (order) of a product (Column A).
I created a simply PivotTable based on this data which gives me the following result:
Count of Sent Quantity Count of Returned Quantity
Product A 3 3
Product B 2 2
Product C 1 1
As you can see it counts all sales (orders) of the product no matter if there is a 0-Return.
Now I want to achieve that sales wich have no returns (0-Value in Column C) are EXCLUDED from the Count of Returned Quantity but it should still be INCLUDED in the Count of Sent Quantity. Therefore, my desired result would be the following:
Count of Sent Quantity Count of Returned Quantity
Product A 3 2
Product B 2 1
Product C 1 0
Do you have any idea how I can achieve this?
You need to insert Calculated field in your pivot which says if Returned Products>0 then 1 else o
and at pivot use sum and not count for this Field

HLOOKUP/VLOOKUP to replace nested IF-functions

I have the following Excel spreadsheet:
A B C D E
1 Sale 1 Sale 2 Sale 3
2 Product A 0 0 400 Sale 3
3 Product B 0 0 300 Sale 3
4 Product C 0 200 0 Sale 2
5 Product D 800 0 0 Sale 1
In Columns B:D you can see the Sales for each product.
In Column E I want to show in which Sale the product was sold.
Therefore, the Sale which is <> 0 should be shown.
I used the following formula so far:
=IF(B3<>0,B$2,WENN(C3<>0,C$2,WENN(D3<>0,D$2)))
This formula works in the upper case quite well but in my orignal example there are much more sales which would expand this formula massively.
Is there a way to shorten the formula so it is not necessary to use so many nested IF-functions?
Maybe somethling like a HLOOKUP with a value <> 0 criteria?
Following formula should be helpful:
=INDEX($B$1:$D$1,MATCH(TRUE,INDEX($B2:$D2<>0,),0))
Drag/Copy down as required.
See image for reference:

SUMPRODUCT with multiple criterias and empty cells

I have the following Excel spreadsheet:
A B C D E F G
1 Profit 1.Sales 2.Sale 3.sale
2 Product A 50 500 600 0 Product A 110
3 Product A 60 0 400 0 Product B 90
4 Prodcut A 20 0 0 0 Product C 130
5 Product B 90 800 0 500
6 Product C 80 0 0 400
7 Product C 50 300 750 200
8 ="" ="" ="" ="" =""
In Column A different products are listed. It can happen that the same products appear several times in the list. In Column B you can find the budgeted profit for each product and in Columns C:E the different sales of each product.
In Column G the sum of the profit of each product is shown in case the product has any sales. For example Product A has no sale in Row 4; therefore the sum of its profit is B2+B3 = 110.
I use the following formula to get the sum of the profit:
G2 = SUMPRODUCT($B$2:$B$7*(($C$2:$C$7>0)+($D$2:$D$7>0)+($E$2:$E$7>0)>0)*($A$2:$A$7=F2))
This formula works perfectly so far.
However, now I want to expand this formula to Row 8.
Row 8 does include =" " which causes a result of #VALUE! of the above formula.
How can I make this formula work despite the =" " in Row 8?
Try SUMPRODUCT() with two arguments:
=SUMPRODUCT($B$2:$B$8,(($C$2:$C$8>0)+($D$2:$D$8>0)+($E$2:$E$8>0)>0)*($A$2:$A$8=F2))

SUMIF(S) with a SUMIF(S) criteria

I have the following Excel spreadsheet:
A B C D E F G
1 Budget Profit 1.Sales 2.Sale 3.sale
2 Product A 50 500 600 0 Product A 100
3 Product A 50 0 400 0 Product B 90
4 Prodcut A 20 0 0 0 Product C 180
5 Product B 90 800 0 500
6 Product C 90 0 0 400
7 Product C 90 300 750 200
In Column A different products are listed. It can happen that the same products appear several times in the list.
In Column B you can find the budgeted profit for each product and in Columns C:E the different sales of each product.
In Column G I want to achieve now that the sum of each product is calculated but only if the sum of the sales (Columns C:E) is >0 or - in other words - if there is any sales for the product the profit should be summed up.
So far I came up with something like this:
=SUMIFS($B$2:$B$7;$A$2:$A$7;F2;$C$2:$E$7;">"&0)
However, this formula does not seem to work. I get an #VALULE! error.
Do you have any idea how I could make this happen?
The SUMIFS() ranges need to be the same size, And since you want OR Not AND You will need to use SUMPRODUCT:
=SUMPRODUCT($B$2:$B$7*(($C$2:$C$7>0)+($D$2:$D$7>0)+($E$2:$E$7>0)>0)*($A$2:$A$7=F2))

SUMPRODUCT with OR criterias

I have the following Excel spreadsheet:
A B C D E F G
1 Profit 1.Sales 2.Sale 3.sale
2 Product A 50 500 600 0 Product A 110
3 Product A 60 0 400 0 Product B 90
4 Prodcut A 20 0 0 0 Product C 130
5 Product B 90 800 0 500
6 Product C 80 0 0 400
7 Product C 50 300 750 200
8 ="" ="" ="" ="" =""
In Column A different products are listed. It can happen that the same products appear several times in the list. In Column B you can find the budgeted profit for each product and in Columns C:E the different sales of each product.
In Column G the sum of the profit of each product is shown in case the product has any sales. For example Product A has no sale in Row 4; therefore the sum of its profit is B2+B3 = 110.
I use the following formula to get the sum of the profit:
G2 = SUMPRODUCT($B$2:$B$8,(($C$2:$C$8>0)+($D$2:$D$8>0)+($E$2:$E$8>0)>0)*($A$2:$A$8=F2))
This formula works perfectly so far.
However, now I want to change this formula to only count in the Products that have a Sale > 500 so I modified the above formula to the following:
G2 = SUMPRODUCT($B$2:$B$8,(($C$2:$C$8>500)+($D$2:$D$8>500)+($E$2:$E$8>500)>500)*($A$2:$A$8=F2))
With this formula I get a value of 0 instead of 50 for Product A.
Where is my mistake in the formula?
Use Formula Auditing ► Evaluate Formula to examine what is happening at each step.
= SUMPRODUCT($B$1:$B$7,((($C$1:$C$7>500)+($D$1:$D$7>500)+($E$1:$E$7>500))>0)*($A$1:$A$7=F2))

Resources