Fun inventory problem

excelhjalp

New Member
Joined
Aug 7, 2018
Messages
33
Office Version
  1. 365
Platform
  1. Windows
Hello!

I have a problem I can't seem to solve. This is for a rental busniess that rents out products and gets them back at a certain date.
I have four tables.

Table A: A daterange based on ID, that's a key between table A and table B
Table B: A table where one or more products can be reserved as well as how many of them. Each ID can be made of multiple products here.
Table C: An Inventory based on dates. Here a formula would be needed for the third column, inventory. It should calculate how many products are available at a given date based on Table A, B and D. It should take the total count of products from table D, and subtract the total number reserved in tables A and B and give a result, for each day specified.
Table D: A simple table where the total number of products is stated.

So the problem is: What formula can I use to calculate total products of each type in stock at a given date in the third column in Table C?

Thanks for those who give this a shot! :D

masterskjal2.3.xlsb.xlsx
ABCDEFGHIJKLMNOPQR
1Table ATable BTable CTable D (Total inventory)
2IDDate fromDate toIDProductCount of productProductDateInventoryFootball3
311.1.20222.1.20221Football2Football1.1.20221Pants5
421.1.20223.1.20221Chair2Football2.1.20223Chair10
533.1.20224.1.20222Pants3Football3.1.20223
63Chair6Football4.1.20223
7Football5.1.20223
8Pants1.1.20225
9Pants2.1.20222
10Pants3.1.20222
11Pants4.1.20225
12Pants5.1.20225
13Chair1.1.20228
14Chair2.1.20228
15Chair3.1.20226
16Chair4.1.20226
17Chair5.1.202210
18
19
20
21
Sheet1
 
What version of Excel are you using?
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
 
Upvote 0

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.
Are you pasting as array formula? It was ok in my sheet 😕
Yup, see the screenshot. It looks like it workes for some part, but does not calculate all days correctly.
1670247514811.png
 
Upvote 0
This doesn't make sense? Are you including upper-bound dates or not?
In your first example, you were not including the upper-bound. See M4
1670247807755.png

My formula can't work if both dates are included.
 
Last edited by a moderator:
Upvote 0
What version of Excel are you using?
I suggest that you update your Account details (or click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)
I'm using 365. I've updated my profile, thanks for letting me know!
 
Upvote 0
Ok this is my last try. This is not an array formula. you can paste normally. However, you are using 365 so you can paste any formula normally :)
Excel Formula:
=LET(i,INDEX($F$3:$F$6,MATCH(K3,$G$3:$G$6,0)),VLOOKUP(K3,$Q$2:$R$4,2,0)-SUMPRODUCT(--($G$3:$G$6=K3)*--(L3>=VLOOKUP(i,$A$3:$C$5,2,0))*--(L3<=VLOOKUP(i,$A$3:$C$5,3,0)),$H$3:$H$6))
I am not sure if this counts multiple instances. Maybe you should wait for @Fluff 's solution.
 
Last edited by a moderator:
Upvote 0
Ok this is my last try. This is not an array formula. you can paste normally. However, you are using 365 so you can paste any formula normally :)
Excel Formula:
=LET(i,INDEX($F$3:$F$6,MATCH(K3,$G$3:$G$6,0)),VLOOKUP(K3,$Q$2:$R$4,2,0)-SUMPRODUCT(--($G$3:$G$6=K3)*--(L3>=VLOOKUP(i,$A$3:$C$5,2,0))*--(L3<=VLOOKUP(i,$A$3:$C$5,3,0)),$H$3:$H$6))
,I am not sure if this counts multiple instances. Maybe you should wait for @Fluff 's solution.
Thanks for all the tries Flashbond! I really appreciate it. This error shows up though when I try this. perhaps there's a bracket in the wrong place?
1670249550987.png
 
Upvote 0
Yes, I updated the formula. Also some semicolons were left because of the regional settings of my excel. Please try the updated formula in post #16.
I believe the third time's the charm.
 
Upvote 0
Yes, I updated the formula. Also some semicolons were left because of the regional settings of my excel. Please try the updated formula in post #16.
I believe the third time's the charm.
It looks like it works, unless the same product is in more than one ID, so f.ex. the chairs are counted wrong. Again, I really appreciate all the efford mate! If you give up (like me) then hopefully @Fluff can shed some light into this :D
 
Upvote 0
How about
Excel Formula:
=VLOOKUP(K3,$Q$2:$R$4,2,0)-FILTER($H$3:$H$6,ISNUMBER(MATCH($F$3:$F$6,FILTER($A$3:$A$5,($B$3:$B$5<=L3)*($C$3:$C$5>=L3),0),0))*($G$3:$G$6=K3),0)
 
Upvote 0
Solution

Forum statistics

Threads
1,223,723
Messages
6,174,123
Members
452,546
Latest member
Rafafa

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top