Skip to main content
Solved

Total open quantity on Production orders for an item by warehouse

  • February 16, 2026
  • 10 replies
  • 26 views

Forum|alt.badge.img

I have a GI that shows the Qty On Hand for each item by Warehouse. I want to get the total quantity on open Production orders at that warehouse for that item.  What tables/DACs do I need to join to my GI to pull in those numbers? 

Best answer by aryanjadhav50

I created a separate GI based on AMProdItem in order to summarize the total quantities by Warehouse and Item (see code below).  Then I referenced that GI in my original one and did a LEFT join on InventoryID and SiteID.

Everything works fine, except for the items that have no matching record in the AMProdItem GI.  Instead of showing a value of 0 or blank or null, it shows a value of 1.0.  

I tried adding a formula like 

=IsNull([PFTOpenProductionTotals.AMProdItem_qtyRemaining],0)

but it gives me an error about using a virtual field in a conditional expression.  How can I fix this?
 

FROM AMProdItem
WHERE AMProdItem.StatusID = 'R'
OR AMProdItem.StatusID = 'I'
GROUP BY
AMProdItem.SiteID,
AMProdItem.InventoryID
SELECT
AMProdItem.SiteID AS 'SiteID',
AMProdItem.InventoryID AS 'InventoryID',
SUM(AMProdItem.QtytoProd) AS 'QtyToProd',
SUM(AMProdItem.QtyComplete) AS 'QtyComplete',
SUM(AMProdItem.QtyRemaining) AS 'QtyRemaining'

 

The issue happens because you’re LEFT joining to a summarized GI. When no matching record exists, the grouped result can evaluate to 1 due to aggregation behavior.

You cannot use IsNull() because the field is already an aggregated (virtual) field.

Best solution (recommended):

Do not use a separate GI. In your main GI:

  • Add AMProdItem directly

  • LEFT join on InventoryID and SiteID

  • Add condition: AMProdItem.StatusID IN ('R','I')

  • Create calculated field:
    AMProdItem.QtytoProd - AMProdItem.QtyComplete

  • Set Aggregate = Sum

  • Group by InventoryID and SiteID

This avoids nested aggregation and will correctly return 0 when no production orders exist.

Hope this works for you.

10 replies

Forum|alt.badge.img

Hi ​@bruno71 

Include INSiteStatus and AMProdItem in the GI to get warehouse-wise open production quantities.

Add a Left Join using:
INSiteStatus.InventoryID = AMProdItem.InventoryID
INSiteStatus.SiteID = AMProdItem.SiteID


Forum|alt.badge.img+9
  • Captain II
  • February 17, 2026

@bruno71 

 

Is it the component item or finished good stock for the production orders you are looking for?


aryanjadhav50
Jr Varsity I
Forum|alt.badge.img
  • Jr Varsity I
  • February 17, 2026

Hi ​@bruno71 
 

To get the total quantity on open Production Orders by Item and Warehouse in your GI, you need to join the Manufacturing production order header table.

Use DAC:

AMProdItem
 

This table contains:
InventoryID, SiteID (Warehouse), QtytoProd, QtyComplete, Status

 

Join conditions:

InventoryItem.InventoryID = AMProdItem.InventoryID
AND
INSite.SiteID = AMProdItem.SiteID

 

In Conditions tab, filter only open production orders.

 

To get open quantity, create a calculated field:

QtytoProd - QtyComplete

 

Apply Sum aggregation on this field and group by:

InventoryID, SiteID

 

This will give total open production quantity by item and warehouse.


abhimanyuprajapati52
Jr Varsity I
Forum|alt.badge.img

Hi ​@bruno71,
If your GI already shows Qty On Hand by warehouse (using INSiteStatus), then:

Add AMProdItem as a Left Join to pull open production quantities.

Join on:

  • INSiteStatus.InventoryID = AMProdItem.InventoryID

  • INSiteStatus.SiteID = AMProdItem.SiteID

Then:

  • Filter AMProdItem.StatusID NOT IN (Closed, Completed, Cancelled)

  • Use AMProdItem.QtyRemaining

  • Aggregate QtyRemaining as SUM

  • Group by InventoryID and SiteID

Using QtyRemaining ensures the total reflects the true open production quantity per item per warehouse.


Forum|alt.badge.img
  • Author
  • Freshman II
  • February 17, 2026

I created a separate GI based on AMProdItem in order to summarize the total quantities by Warehouse and Item (see code below).  Then I referenced that GI in my original one and did a LEFT join on InventoryID and SiteID.

Everything works fine, except for the items that have no matching record in the AMProdItem GI.  Instead of showing a value of 0 or blank or null, it shows a value of 1.0.  

I tried adding a formula like 

=IsNull([PFTOpenProductionTotals.AMProdItem_qtyRemaining],0)

but it gives me an error about using a virtual field in a conditional expression.  How can I fix this?
 

FROM AMProdItem
WHERE AMProdItem.StatusID = 'R'
OR AMProdItem.StatusID = 'I'
GROUP BY
AMProdItem.SiteID,
AMProdItem.InventoryID
SELECT
AMProdItem.SiteID AS 'SiteID',
AMProdItem.InventoryID AS 'InventoryID',
SUM(AMProdItem.QtytoProd) AS 'QtyToProd',
SUM(AMProdItem.QtyComplete) AS 'QtyComplete',
SUM(AMProdItem.QtyRemaining) AS 'QtyRemaining'

 


abhimanyuprajapati52
Jr Varsity I
Forum|alt.badge.img

Hi ​@bruno71,
Join AMProdItem directly into your main GI and perform the SUM(QtyRemaining) aggregation there instead of referencing a summarized GI. Once aggregation happens inside the same GI, null values will behave correctly and the 1.0 issue will disappear.


aryanjadhav50
Jr Varsity I
Forum|alt.badge.img
  • Jr Varsity I
  • Answer
  • February 18, 2026

I created a separate GI based on AMProdItem in order to summarize the total quantities by Warehouse and Item (see code below).  Then I referenced that GI in my original one and did a LEFT join on InventoryID and SiteID.

Everything works fine, except for the items that have no matching record in the AMProdItem GI.  Instead of showing a value of 0 or blank or null, it shows a value of 1.0.  

I tried adding a formula like 

=IsNull([PFTOpenProductionTotals.AMProdItem_qtyRemaining],0)

but it gives me an error about using a virtual field in a conditional expression.  How can I fix this?
 

FROM AMProdItem
WHERE AMProdItem.StatusID = 'R'
OR AMProdItem.StatusID = 'I'
GROUP BY
AMProdItem.SiteID,
AMProdItem.InventoryID
SELECT
AMProdItem.SiteID AS 'SiteID',
AMProdItem.InventoryID AS 'InventoryID',
SUM(AMProdItem.QtytoProd) AS 'QtyToProd',
SUM(AMProdItem.QtyComplete) AS 'QtyComplete',
SUM(AMProdItem.QtyRemaining) AS 'QtyRemaining'

 

The issue happens because you’re LEFT joining to a summarized GI. When no matching record exists, the grouped result can evaluate to 1 due to aggregation behavior.

You cannot use IsNull() because the field is already an aggregated (virtual) field.

Best solution (recommended):

Do not use a separate GI. In your main GI:

  • Add AMProdItem directly

  • LEFT join on InventoryID and SiteID

  • Add condition: AMProdItem.StatusID IN ('R','I')

  • Create calculated field:
    AMProdItem.QtytoProd - AMProdItem.QtyComplete

  • Set Aggregate = Sum

  • Group by InventoryID and SiteID

This avoids nested aggregation and will correctly return 0 when no production orders exist.

Hope this works for you.


Forum|alt.badge.img
  • Author
  • Freshman II
  • February 18, 2026

Got it...thanks!  The parent GI is already doing several things, so I was trying to simplify it by separating out the aggregated totals.  Otherwise, I’ll have to figure out how to add the Group By for the other columns and calculated values I’m using.


dgodsill97
Varsity I
Forum|alt.badge.img+5
  • Varsity I
  • February 18, 2026

You could have just used the same DAC (INSiteStatus) you used for the QtyOnHand.  There are 2 columns to sum QtyProductionSupplyPrepared (orders that have a status of planned or on hold) or QtyProductionSupply (released or on process).  


Forum|alt.badge.img
  • Author
  • Freshman II
  • February 19, 2026

You could have just used the same DAC (INSiteStatus) you used for the QtyOnHand.  There are 2 columns to sum QtyProductionSupplyPrepared (orders that have a status of planned or on hold) or QtyProductionSupply (released or on process).  

Thanks!  I’ll check this out.