Index match help with division

proficient

Well-known Member
Joined
Apr 10, 2012
Messages
745
Office Version
  1. 2016
Platform
  1. Windows
  2. Mobile
Hello all,

I have shared two tables below, first one is a DATA SOURCE and second one is the DESIRED RESULT. I want the DESIRED RESULT in yellow highlighted columns in the 2nd table.

I am looking for a particular formula which can read and match the product ID from DATA SOURCE and distribute the quantity in their respective column's cell, furthermore the quantity distributed by the formula shall not exceed from the CUT QUANTITY of that particular product ID.

Book1.xlsx
BCDFGHIJKL
1DATA SOURCE
2PRODUCT IDCUSTOMEROCS SHIPMENT DATECUT QTY (3% EXTRA)TOTAL CUTBALANCETOTAL OUTPUTBALANCETOTAL SENT TO WASHSENT TO WASH BALANCE
35064H & M5-Jul30903090002950-1402500-450
45066H & M5-Jul41203500-6202796-7041022-1774
55027-2H & M5-Jul51504250-9003795-4551881-1914
6
7DESIRED RESULT
8PRODUCT IDCUSTOMEROCS SHIPMENT DATECUT QTY (3% EXTRA)TOTAL CUTBALANCETOTAL OUTPUTBALANCETOTAL SENT TO WASHSENT TO WASH BALANCE
95066H & M5-Jul18541854001854001022-832
105064H & M5-Jul1545154500154500154500
115027-2H & M5-Jul32963296003296001881-1415
125066H & M6-Jul1236123600942-29400-942
135064H & M6-Jul1030103000103000955-75
145066H & M7-Jul1030410-62000-4100000
155064H & M7-Jul51551500375-14000-375
165027-2H & M7-Jul1854954-900499-45500-499
Sheet2
 
Hello Jason, Your provided formula is working fine on example sheet but is not working in original sheet and skipping output result (showing blank). I don't know why.

Note: I have replaced VLOOKUP with INDEX & MATCH and I hope it won't affect on formula performance as it is working fine in example sheet.
 
Upvote 0

Excel Facts

Why does 9 mean SUM in SUBTOTAL?
It is because Sum is the 9th alphabetically in Average, Count, CountA, Max, Min, Product, StDev.S, StDev.P, Sum, VAR.S, VAR.P.
=MEDIAN(0,O3,INDEX(DataSource!$Q$3:$Q$247,MATCH('Shipment plan'!C3,DataSource!$E$3:$E$247,0))-SUMIF(DataSource!E3,'Shipment plan'!C3,'Shipment plan'!$P$2:P2))

I am getting correct answer if I use above formula, instead of range I just used single cell formula.
 
Upvote 0
The first range in the sumif part was looking at the wrong sheet. I'm assuming that the formulas are in the shipment plan sheet so you don't need to use the sheet name there.

I think that this should be right but it is only best guess without having seen the layout of your sheets.
Excel Formula:
=MEDIAN(0,$O3,INDEX(DataSource!$Q$3:$Q$247,MATCH($C3,DataSource!$E$3:$E$247,0))-SUMIF($C$2:$C2,$C3,$P$2:$P2))

For Total Cut, the correct result should never be less than 0 or more than Cut Qty (3% extra) so those are used as the first 2 values of median.
The 3rd value is what is outstanding for the current product (initial qty from the source table minus total of previous rows for the same product in the shipment plan).
Depending on the qty already shipped, if there is still more to ship after the current row then the result will be greater than Cut Qty and greater than 0. In this case Cut Qty will be the median value because it is greater than 0 but less then the amount remaining to ship.

If the amount remaining to ship is greater than 0 but less than Cut Qty then the amount remaining to ship will be the median. If it is less than 0 (overship calculated) then 0 will be the median.

You may have seen other threads where =MIN(MAX(....)) has been used, which works on a similar basis.
 
Upvote 0
I'll check the formula tomorrow and let you know.

Thank you for the detailed explanation.
 
Upvote 0
Hello Jason, I am sharing link of original file, please download and check.

I have placed all the formula in Shipment Plan tab and highlighted the columns with yellow color and extracting the data from DataSource tabs.

LINK:

 
Upvote 0
I'll have a look at it when I get chance but that might not be for a couple of days.
 
Upvote 0
I don't see what the issue is, the formula in post 13 is correct for P13. The only reason it is not working is because you haven't changed it.
 
Upvote 0

Forum statistics

Threads
1,223,911
Messages
6,175,325
Members
452,635
Latest member
laura12345

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