I need help with a formula calculating qty in and out based on need date where oldest date pulls first if the PN matches an item on the inventory list.
I have a master list of total on-hand inventory.
PN
Total QTY on-Hand
aaa
10
bbb
15
ccc
0
I need to compare the total on-hand inventory list with individual order lines, but I cannot figure out how to get the remaining balance to be the starting balance (QTY OH column) of the next line. Below is what I would like it to look like.
Date Due
PN
QTY OH
QTY Demand
QTY Balance
1/15/2023
aaa
10
2
8
1/17/2023
aaa
8
3
5
1/20/2023
aaa
5
4
1
1/19/2023
bbb
15
11
4
1/25/2023
bbb
4
6
-2
1/30/2023
bbb
-2
3
-5
1/11/2023
ccc
0
8
-8
1/16/2023
ccc
-8
7
-15
1/21/2023
ccc
-15
4
-19
I have tried helper columns with vLookup (can't get away from circular references) and multiple IF/AND/OR statements. I can do SumProduct and SumIf, but I need to know the qty by the individual demand, not just the total. Is this something I can do with a formula or I need to move to VBA?
Subtract the sum of the qty demand(SUMIFS) to that point from the original qty on hand.
=VLOOKUP(B2,H:I,2,0)-SUMIFS($D$1:D1,$B$1:B1,B2)
Note what is and what is not absolute referencing. As the formula is dragged down it will only refer to the values above.
And, as you can see, since we are using conditional formula it does not matter that it is sorted by date instead of by PN and Date:
Related
A B C D E F G H
1 Products Date Sales Criteria 1: Product_B Result: 200
2 Product_A 2020-04-15 500 Criteria 2: 2020-04-15
3 Product_B 2020-04-12 600
4 Product_B 2020-04-12 300
5 Product_B 2020-04-15 200
6 Product_B 2020-04-20 400
7 Product_C 2020-04-15 800
8 Product_C 2020-04-19 900
9 Product_C 2020-04-30 300
10
11
In the table above I have different products and their sales on a certain date.
In Cell G1 I calculate sum of the sales based on the criterias in Cell E1 and E2.
G1 = SUMPRODUCT((($A$2:$A$100=$E$1)*($B$2:$B$100=$E$2)*$C$2:$C$100))
All this works exactly as it should.
Now, I want to include an IF-Condition that says if you enter the words "All Products" into Cell E1 the product condition ($A$2:$A$100=$E$1) in the SUMPRODUCT should not be applied.
Therefore, I tried to go with this:
= SUMPRODUCT((IF(E1="All Products",1,($A$2:$A$100=$E$1))*($B$2:$B$100=($E$2))*$C$2:$C$100))
Unfortunately, this solution only works if I enter "All Products" into Cell E1.
Once I switch back to Product_B it displays 0 instead of 200.
What do I need to change to make it work?
NOTE:
I know one solution could be to split the SUMPRODUCT into two formulas like this:
=IF(E1="All Products",SUMPRODUCT((($B$2:$B$100=$E$2)*$C$2:$C$100)),SUMPRODUCT((($A$2:$A$100=$E$1)*($B$2:$B$100=$E$2)*$C$2:$C$100)))
However, I would prefer a solution with one SUMPRODUCT-Formula.
With SUMIFS:
=SUMPRODUCT(SUMIFS($C:$C,$A:$A,IF(E1="All Products","*",$E$1),$B:$B,$E$2))
Combining with your LAST QUESTION
=SUMPRODUCT(SUMIFS($C:$C,$A:$A,IF(E1="All Products","*",$E$1),$B:$B,$E$2:$E$3))
Modify the column A criteria as follows:
=SUMPRODUCT((($A$2:$A$100=$E$1)+($E$1="All Products")*($A$2:$A$100=$A$2:$A$100))*($B$2:$B$100=$E$2)*$C$2:$C$100)
The new factor +($E$1="All Products")*($A$2:$A$100=$A$2:$A$100) will ensure a vector of all 1 with the appropriate input in E1:
Array (Control+Shift+Enter) formula in F2
=SUMPRODUCT(IF((E1<>"All Products"),(A2:A9=E1),TRUE)*(B2:B9=E2)*(C2:C9))
Following Array formula is better than the above one. If you enter anything that doesn't match in column A it will consider it as "All Products"
=SUMPRODUCT(IF(COUNTIF(A2:A9,E1)=0,TRUE,(A2:A9=E1))*(B2:B9=E2)*(C2:C9))
OR
=SUMPRODUCT(IF(ISNA(MATCH(E1,A2:A9,0)),TRUE,(A2:A9=E1))*(B2:B9=E2)*(C2:C9))
I'm trying to use Excle's SUMIF to calculate totals of Col1 to Col5 for dates that are similar.
My formula is as follows =SUMIF($A2:$A7,A10,$B2:$F7), but this only gives me the total of a single column.
How can I get the Totals of all the columns based on the date like I've shown in my results.
Date Col 1 Col 2 Col 3 Col 4 Col 5
1/5/2017 1 2 2
1/5/2017 5 3 1
1/5/2017 9 5 5
2/5/2017 10 5 3
2/5/2017 20 10 3
2/5/2017 6 8 1 5
Desired Results
1/5/2017 15 7 7 3 1
2/5/2017 30 11 11 11 8
use below formula in cell B11
=SUMIF($A$2:$A$7,$A11,B$2:B$7)
Per the example you provided, One solution is to use SUMPRODUCT
Multiplies corresponding components in the given arrays, and returns the sum of those products
Microsoft Docs give a thorough example, but per SO etiquette, here is an example in case of link-rot: [FYI, I used absolute reference for easier filling across, arbitrary how you get it done though]
Forumlas shown:
Formula is kind of hard to see without clicking on image:
=SUMPRODUCT(($B$3:$B$8=$B$11)*C3:C8)
This basically breaks down like this, it searches the B:B column for a match, and it will naturally return a true or false for the match, or 0/1 counterparts, and multiplys that by the number found in the column to the right (C3:C8), so it will either be 1 * # = # or 0 * # = 0
I have 3 Columns, B,C and D.
Columns B,C,D will be updated periodically and the number of rows will be increased day by day.
Columns B contains NAME, C contains Quantity and D has Date value.
Name Qt Date
SSS 20
SSS 30
NNN 50
PPP 40 13-Jul-15
PPP 20 13-Jul-15
AAA 20
CCC 100
GGG 300
FFF 200
BBB 50 28-Aug-15
AAA 20
GGG 100
BBB 30
JJJ 50
BBB 30
FFF 50
FFF 25 24-Aug-15
CCC 75
JJJ 30
FFF 50
JJJ 36 24-Aug-15
FFF 50 24-Aug-15
I need the result as below.
Name Qt
AAA 40
BBB 30
CCC 175
FFF 300
GGG 400
JJJ 80
NNN 50
SSS 50
Rows with date field(column D) having a value should be omitted from adding.
Name field can contain any name and future names can vary from current names.
The Result can be in the same sheet or in the different sheet.
This may not meet your exact needs but it should get you the data you want in the first instance.
In Excel select the Insert tab and select Pivot Table.
Set the table range to be A1 to C60000 (or whatever the max number of rows is)
Select New Worksheet and click OK.
Add the Name and Qt fields to the report. It should automatically sum Qt.
Add Date to the Filters. This should add a bar above the pivot table that says something like:
Date (All)
Click on (All) and select (blank), and that should exclude the rows with dates specified.
use helper cells next to the date range =isblank(d2) this will return TRUE in E2
put AAA in G6, in H6 put the following formula =SUMIFS(C:C,E:E,"TRUE",B:B,G6)
if there is trash data in the blank cells like random spaces and whatnot use =isblank(trim(d2))
i loooove pivot tables but sometimes they just make file sizes too big if using a bunch of them in a single workbook, i also get tired of refreshing them.
With the following data:
A B
1 CUMULATIVE PERCENTAGE OF ITEMS PRODUCED PER MONTH ("COMPLETION_TABLE")
2 Type Month 1 Month 2
3 KITTENS 0 10
4 FISH 0 20
5 BANANAS 2 5
6 APPLES 0 0
7 PEARS 0 5
8 KITTENS 0 5
9
10
11 PRICES TABLE ("PRICES_TABLE")
12 Type Value
13 APPLES 1000
14 BANANAS 5000
15 PEARS 3000
16 FISH 4000
17 KITTENS 2000
I'm attempting to use the SUMPRODUCT function to calculate the percentage change in each month and use that value as a multiple of the prices table to provide a total price per month across all types that have been produced.
I can calculate the movement as:
=SUMPRODUCT((COMPLETION_TABLE[Month 2]-COMPLETION_TABLE[Month 1]))
... but I then need to calculate the portion of the individual movement values against the price for that type and sum the resulting products together. I have been using various INDEX / MATCH combinations without much luck.
As an example: BANANAS which should =(5-2)*5000.
Written as expanded arrays I would like to do
({10;20;5;0;5;5}-{0;0;2;0;0;0})*{2000;4000;5000;1000;3000;2000}.
Use of SUMPRODUCT implies you want a single figure result. You can use SUMIF as a "pseudo lookup" within SUMPRODUCT to get the prices, e.g.
=SUMPRODUCT(C3:C8-B3:B8,SUMIF(A13:A17,A3:A8,B13:B17))
That would get you a result of 140,000 for your example
From your question I understand the result you want is an array. This is what you get with this formula:
=INDEX($B$13:$B$17,MATCH($A3:$A8,$A$13:$A$17,0))*($C3:$C8-$B3:$B8)
entered as an array formula using Ctrl Shift Enter.
I am sure there is something simpler. I am assuming that the Type in the Price Table are unique:
{=(SUM((A13=$A$3:$A$8)*$C$3:$C$8)-SUM((A13=$A$3:$A$8)*$B$3:$B$8))*SUM((A13=$A$13:$A$17)*$B$13:$B$17)
What I want to do (if possible) is sum each metric of each transaction with a common customer_id in ONE STEP. The output should look like the "DESIRED OUTPUT" sheet. I know some sort of lookup will need to be used to reference the "CUSTOMER LOOKUP" table.
I can see how to accomplish this using VLOOKUP then SUMIF (or the other way around), but I would like to accomplish it using a single formula if possible.
TRANSACTIONS
transaction customer_id metric_1 metric_2
1 1 0 564
2 1 0 762
3 1 5.305 8367
4 2 0 150
5 2 3.125 4109
6 2 6.18 1853
7 3 0 61
8 3 0 1
9 3 0 4
CUSTOMER LOOKUP
customer_id customer_name
1 XXX
2 YYY
3 ZZZ
DESIRED OUTPUT
customer_name metric_1 metric_2
XXX 5.305 9693
YYY 9.305 6112
ZZZ 0 66
I doubt it can be done with one formula. This is a very common scenario and is typically solved by adding a Vlookup column to the first table to show the customer name.
Then you can build a pivot table with a few clicks.
I guess, since using a pivot table does not involve formulas, the only formula you need is the Vlookup. So, yes, it can be done with one formula ;-)