Okay. I tried to simulate your source table,
tDTA in sheet [highlight #4E9A06]SrtDta[/highlight]
[pre]
ProductType ItemCode ItemCodeDesc QOH QPO Dte Qty
F 100KIFS 100GSM WHITE King Fitted Sheet 150 0 1-May 1
F 100KIFS 100GSM WHITE King Fitted Sheet 150 0 1-Jun 3
F 100QUFS 100GSM WHITE Queen Fitted Shee 155 0 1-Apr 1
F 100QUFS 100GSM WHITE Queen Fitted Shee 155 0 1-Feb 2
F 100QUFS 100GSM WHITE Queen Fitted Shee 155 0 1-May 4
F 100QUFS 100GSM WHITE Queen Fitted Shee 155 0 1-Jun 15
[/pre]
Here's my solution assuming that the source table data for the desired date range has been downloaded to a sheet and that table in Excel I call
tDTA, a Structured Table.
My QUERY results is this in sheet [highlight #4E9A06]InvPru[/highlight]...
[pre]
ProductType ItemCode ItemCodeDesc QOH QPO
F 100KIFS 100GSM WHITE King Fitted Sheet 150 0
F 100QUFS 100GSM WHITE Queen Fitted Shee 155 0
[/pre]
Then I added these heading for the pivot...
[pre]
[highlight #FCAF3E]2018[/highlight] 1 2 3 4 5 6 7 8
ProductType ItemCode ItemCodeDesc QOH QPO QOO Jan Feb Mar Apr May Jun Jul Aug Qty Available
F 100KIFS 100GSM WHITE King Fitted Sheet 150 0 4 [highlight #FCE94F]0[/highlight] 0 0 0 1 3 0 0 146
F 100QUFS 100GSM WHITE Queen Fitted Shee 155 0 22 0 2 0 1 4 15 0 0 133
[/pre]
The Formula
[tt]
[highlight #FCE94F]=SUMPRODUCT(
(tDTA[Qty])*
(tDTA[ProductType]=[@ProductType])
*(tDTA[ItemCode]=[@ItemCode])
*(tDTA[ItemCodeDesc]=[@ItemCodeDesc])
*(tDTA[QOH]=[@QOH])
*(tDTA[QPO]=[@QPO])
*(tDTA[Dte]=DATE([highlight #FCAF3E]SelectedYR[/highlight],G$1,1)))[/highlight]
[/tt]
I have uploaded your workbook with my additions
Oh, yes, here's my SQL
Code:
SELECT DISTINCT
a.ProductType
, a.ItemCode
, a.ItemCodeDesc
, a.QOH
, a.QPO
FROM `C:\Users\Skip\Downloads\InventoryPurchasing.xlsx`.`SrcDta$` a
Skip,
Just traded in my OLD subtlety...
for a NUance!![[tongue] [tongue] [tongue]](/data/assets/smilies/tongue.gif)