Lookup multiple values, find minimum amount and return another value

thevidablue

New Member
Joined
Mar 5, 2018
Messages
4
Hi
I have a tricky formula I cannot figure out myself. Tried various combination with no real luck. Simply over my head :eek:

First off, my "masterdata" in one tab looks like below:

TRADE
POL
Carrier
Value
AFRICA
SEGOT
HPLU
700
AFRICA
SEHEL
HPLU
800
AFRICA
SENRK
HPLU
850
AFRICA
SEGOT
MAEU
750
AFRICA
SEHEL
MAEU
900
AFRICA
SENRK
MAEU
700
AFRICA
SEGOT
NYKU
775
AFRICA
SEHEL
NYKU
950
AFRICA
SENRK
NYKU
650
AFRICA
SEGOT
OOLU
800
AFRICA
SEHEL
OOLU
950
AFRICA
SENRK
OOLU
950
AMNO
SEGOT
HPLU
500
AMNO
SEHEL
HPLU
600
AMNO
SENRK
HPLU
650
AMNO
SEGOT
MAEU
450
AMNO
SEHEL
MAEU
500
AMNO
SENRK
MAEU
550
AMNO
SEGOT
NYKU
550
AMNO
SEHEL
NYKU
700
AMNO
SENRK
NYKU
500
LATAM
SEGOT
OOLU
900
LATAM
SEHEL
OOLU
1100
LATAM
SENRK
OOLU
1100
LATAM
SEGOT
MAEU
1100
LATAM
SEHEL
MAEU
1300
LATAM
SENRK
MAEU
1300
LATAM
SEGOT
COSU
800
LATAM
SEHEL
COSU
1000
LATAM
SENRK
COSU
1000
SPAC
SEGOT
HPLU
1000
SPAC
SEHEL
HPLU
1100
SPAC
SENRK
HPLU
1100
SPAC
SEGOT
COSU
800
SPAC
SEHEL
COSU
700
SPAC
SENRK
COSU
700
SPAC
SEGOT
MAEU
900
SPAC
SEHEL
MAEU
1200
SPAC
SENRK
MAEU
1200

<tbody>
</tbody>


In a separate tab I want to find the following results:

TRADE
POL
Carrier 1
Carrier 2
Carrier 3
Carrier 4
AFRICA
SEGOT
HPLU
MAEU
NYKU
OOLU
AFRICA
SEHEL
HPLU
MAEU
NYKU
OOLU
AFRICA
SENRK
NYKU
MAEU
HPLU
OOLU
AMNO
SEGOT
MAEU
HPLU
NYKU
-
AMNO
SEHEL
MAEU
HPLU
NYKU
-
AMNO
SENRK
NYKU
MAEU
HPLU
-
LATAM
SEGOT
COSU
OOLU
MAEU
-
LATAM
SEHEL
COSU
OOLU
MAEU
-
LATAM
SENRK
COSU
OOLU
MAEU
-
SPAC
SEGOT
COSU
MAEU
HPLU
-
SPAC
SEHEL
COSU
HPLU
MAEU
-
SPAC
SENRK
COSU
HPLU
MAEU
-

<tbody>
</tbody>


So, to automize the values in carrier 1, carrier 2, carrier 3 & carrier 4 I need to look up "trade" and "POL", find the lowest value in column four and once this is found return the value in "carrier".

The masterdata is 2600 rows long, sometimes there is only one carrier, sometimes there are ten. I want to find the cheapeast one and display it in "carrier 1", I then want to display the second cheapest one in "carrier 2", third cheapest in "carrier 3" and fourth in "carrier 4".

Can this be done via vlookup+MIN somehow, or via index/match+MIN?

Many thanks in advance!!!
Daniel
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
try this


Excel 2013/2016
ABCD
1TRADEPOLCarrierValue
2AFRICASEGOTHPLU700
3AFRICASEHELHPLU800
4AFRICASENRKHPLU850
5AFRICASEGOTMAEU750
6AFRICASEHELMAEU900
7AFRICASENRKMAEU700
8AFRICASEGOTNYKU775
9AFRICASEHELNYKU950
10AFRICASENRKNYKU650
11AFRICASEGOTOOLU800
12AFRICASEHELOOLU950
13AFRICASENRKOOLU950
14AMNOSEGOTHPLU500
15AMNOSEHELHPLU600
16AMNOSENRKHPLU650
17AMNOSEGOTMAEU450
18AMNOSEHELMAEU500
19AMNOSENRKMAEU550
20AMNOSEGOTNYKU550
21AMNOSEHELNYKU700
22AMNOSENRKNYKU500
23LATAMSEGOTOOLU900
24LATAMSEHELOOLU1100
25LATAMSENRKOOLU1100
26LATAMSEGOTMAEU1100
27LATAMSEHELMAEU1300
28LATAMSENRKMAEU1300
29LATAMSEGOTCOSU800
30LATAMSEHELCOSU1000
31LATAMSENRKCOSU1000
32SPACSEGOTHPLU1000
33SPACSEHELHPLU1100
34SPACSENRKHPLU1100
35SPACSEGOTCOSU800
36SPACSEHELCOSU700
37SPACSENRKCOSU700
38SPACSEGOTMAEU900
39SPACSEHELMAEU1200
40SPACSENRKMAEU1200
Sheet1



Excel 2013/2016
ABCDEF
1TRADEPOLCarrier 1Carrier 2Carrier 3Carrier 4
2AFRICASEGOTHPLUMAEUNYKUOOLU
3AFRICASEHELHPLUMAEUNYKUNYKU
4AFRICASENRKNYKUMAEUHPLUOOLU
5AMNOSEGOTMAEUHPLUNYKU
6AMNOSEHELMAEUHPLUNYKU
7AMNOSENRKNYKUMAEUHPLU
8LATAMSEGOTCOSUOOLUMAEU
9LATAMSEHELCOSUOOLUMAEU
10LATAMSENRKCOSUOOLUMAEU
11SPACSEGOTCOSUMAEUHPLU
12SPACSEHELCOSUHPLUMAEU
13SPACSENRKCOSUHPLUMAEU
Sheet2
Cell Formulas
RangeFormula
C2{=IFERROR(INDEX(Sheet1!$C$2:$C$40,MATCH($A2&$B2&SMALL(IF(Sheet1!$A$2:$A$40=$A2,IF(Sheet1!$B$2:$B$40=$B2,Sheet1!$D$2:$D$40)),COLUMN(Sheet1!N1)-COLUMN(Sheet1!$M$1)),Sheet1!$A$2:$A$40&Sheet1!$B$2:$B$40&Sheet1!$D$2:$D$40,0)),"")}
Press CTRL+SHIFT+ENTER to enter array formulas.
 
Upvote 0
Thanks for the quick help! Tried to insert this exactly as advised, excel accepts the formula but IFERROR kicks in and returns a blank value. Any idea why?
 
Upvote 0
Thanks for the quick help! Tried to insert this exactly as advised, excel accepts the formula but IFERROR kicks in and returns a blank value. Any idea why?

Most likely tab names? The formula calls Sheet1 and Sheet2 - I bet you've named your sheets otherwise.
 
Upvote 0
Thanks for the quick help! Tried to insert this exactly as advised, excel accepts the formula but IFERROR kicks in and returns a blank value. Any idea why?

have you confirmed with Ctrl+Shift+Enter?
 
Upvote 0
Nope, they are correcly named and data is in the same cells. Very strange. Is it possible to send me a working workbook-copy somehow?
 
Upvote 0
Nope, they are correcly named and data is in the same cells. Very strange. Is it possible to send me a working workbook-copy somehow?

Code:
=IFERROR(INDEX(Sheet1!$C$2:$C$40,MATCH($A2&$B2&SMALL(IF(Sheet1!$A$2:$A$40=$A2,IF(Sheet1!$B$2:$B$40=$B2,Sheet1!$D$2:$D$40)),COLUMN(Sheet1!N1)-COLUMN(Sheet1!$M$1)),Sheet1!$A$2:$A$40&Sheet1!$B$2:$B$40&Sheet1!$D$2:$D$40,0)),"")

is an array formula that you have to enter with Ctrl+Shift+Enter together without the {}, the {} will appear automatically if enter correctly.

here is the sample file

https://drive.google.com/file/d/11aGqC6lzrw3H4sNI9RqCnSsliKzbiYmW/view?usp=sharing
 
Upvote 0

Forum statistics

Threads
1,214,584
Messages
6,120,385
Members
448,956
Latest member
JPav

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