max of

el c

New Member
Joined
Mar 24, 2020
Messages
16
Office Version
  1. 365
Platform
  1. Windows
Hi, I'm new to this forum.

I have an excel sheet with over 2000 rows. I want to have the maximum number of the Quantity of each item Code when the location is the same. For example, you can see in the excel sheet i have the ItemCode :
389-12-040110701
4.00​
1​
1107010A
389-12-040110701
65.00​
1​
1107010A
389-12-040110701
35.00​
1​
1107010A
As you can see the item Code and the Location Code are the same in every row. I want to keep only the Maximum of the numbers 4.00, 65.00, 35.00 for the whole sheet. How can I do this without altering the rest of the data that is related to them?

in this link you can see the excel sheet
 

Excel Facts

What did Pito Salas invent?
Pito Salas, working for Lotus, popularized what would become to be pivot tables. It was released as Lotus Improv in 1989.
There are probably better ways to do this, but see if this gives the intended results. Unique values for the matched pairs of Item Code and Location Code are first found (I concatenated those two to simplify finding unique combinations, but that complicates the next step)...see the concatenated result of those two in column I. Then the Item Code and Location Code are extracted from that concatenation (see columns J and K). Then the AGGREGATE function is used to find all instances where Item Code and Location Code match the unique combination just identified and the corresponding Quantity for each of those...and the largest of those quantities is selected. I've only included a snapshot of your file and the additional columns I created to the right of your data. If the formulas work for your purposes, simply copy them down the sheet until the column I formula no longer finds anything unique (row 459 should be the last one with an output).

inventories.xlsx
ABCDEFGHIJKL
1Item CodeRackSlotQuantityLevel[Location.Code]ABCItem / Location CodeItem Code[Location.Code]Max Quantity
2257-30-015110515.0011105010A257-08-011 / 1115130257-08-01111151306
3389-12-04011071411107010A311-12-802 / 1111180311-12-802111118015
4389-12-040110716511107010A257-12-801 / 1109160257-12-80111091601
5389-12-040110713511107010A257-08-010 / 1105060257-08-01011050605
6257-30-01411079111107090A257-15-502 / 1105040257-15-502110504012
7257-30-01411079311107090A257-12-803 / 1101080257-12-80311010806
8010-30-00411151311115010C257-12-103 / 1125190257-12-10311251903
9367-66-40011153111115030B311-12-142 / 1123160311-12-14211231607
10311-12-141112713111127130A298-12-022 / 1123100298-12-02211231008
11311-12-141112713711127130A010-30-083 / 1123020010-30-083112302046
12311-12-141112713311127130A311-12-144 / 1115210311-12-14411152108
Φύλλο1
Cell Formulas
RangeFormula
I2:I12I2=LOOKUP(2,1/(COUNTIF($I$1:I1,$A$2:$A$2358 & " / " & $F$2:$F$2358)=0),$A$2:$A$2358 & " / " & $F$2:$F$2358)
J2:J12J2=LEFT(I2,SEARCH("/",I2)-2)
K2:K12K2=(RIGHT(I2,LEN(I2)-SEARCH("/",I2)-1))/1
L2:L12L2=AGGREGATE(14,6,--($A$2:$A$2358=J2)*--($F$2:$F$2358=K2)*$D$2:$D$2358,1)
 
Upvote 0
Thank you for your reply KRice. Can you send the example of the data in an excel file? when i copy-paste the Cell Formulas it appears error.
 
Upvote 0
Click on the icon appearing in the upper left corner of the worksheet that I posted...at the intersection of the row numbers and column letters. That will copy the entire contents of the snapshot that I posted to your clipboard, and then you can paste that into your sheet. You will probably want to confirm that it works on a small portion of your worksheet first. Confirm that the cell references match yours, or change the formulas to adapt them to your data table.
 
Upvote 0
Thank you very much. It works now in Microsoft Excel, in google spreadsheets it doesn't work but no need for that.
 
Upvote 0
How can i add the A,B,C labels that i had next to the location Code?
 
Upvote 0
In the first cell under your new ABC column heading, insert this formula:
=INDEX($G$2:$G$2358,MATCH(1,(J2=$A$2:$A$2358)*(K2=$F$2:$F$2358)*(L2=$D$2:$D$2358),0))
where the large range references mentioning G, A, F, and D are your original ABC, Item Code, Location Code, and Quantity columns...change these references where necessary.
After entering this in the first cell, hit F2 followed by Ctrl-Shift-Enter to convert the formula to an array formula (you should see curly brackets inserted in the formula bar. Then grab the small square "handle" appearing in the lower right corner of that cell and drag the formula all the way down that column to the end to match the length of the other data in the new table.
 
Upvote 0
Thank you very much, you've been very helpful.
 
Upvote 0
You're welcome...and welcome to the MrExcel board. I'm glad to help.
 
Upvote 0

Forum statistics

Threads
1,214,832
Messages
6,121,850
Members
449,051
Latest member
excelquestion515

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