I'm building a little app that calculates the inventory gap between whats on-hand and what is forecast to be needed.
This database keeps track of the stock of [Electrodes], which [Part] they are needed to produce, and how many parts can be produced per electrode, [Parts Per Electrode]
For each [Part] there is a [Part Qty] that is the amount of that part that is ordered for the month.
The relationship between parts and electrodes is many-to-many, maintained in a "helper" table.
Here's my issue. I almost have everything working. As you can see below, I can spit out a result of how many electrodes need to be ordered for the month, but the parts are repeated, which means that it is subtracting the electrodes needed from the total stock of electrodes on hand for each entry, and not aggregating the total amount needed to subtract first. That was a confusing sentence - basically, each row assumes that the stock is fully loaded before checking to see if there is "enough" - whereas, in reality, some of the stock should already be accounted for by previous rows.
So, I tried to remove the "Parts" column, so that it is grouped on Electrodes. This is one step forward and two steps back, because now it double counts the inventory (it thinks I have 'n' times the amount of electrodes than I actually do, where 'n' is the number of times that electrode appears in the order).
I hope this explanation made sense. Any ideas how I can get this to work right?