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 :eeek:

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

[TABLE="width: 399"]
<tbody>[TR]
[TD]TRADE
[/TD]
[TD]POL
[/TD]
[TD]Carrier
[/TD]
[TD="align: right"]Value
[/TD]
[/TR]
[TR]
[TD]AFRICA
[/TD]
[TD]SEGOT
[/TD]
[TD]HPLU
[/TD]
[TD="align: right"]700
[/TD]
[/TR]
[TR]
[TD]AFRICA
[/TD]
[TD]SEHEL
[/TD]
[TD]HPLU
[/TD]
[TD="align: right"]800
[/TD]
[/TR]
[TR]
[TD]AFRICA
[/TD]
[TD]SENRK
[/TD]
[TD]HPLU
[/TD]
[TD="align: right"]850
[/TD]
[/TR]
[TR]
[TD]AFRICA
[/TD]
[TD]SEGOT
[/TD]
[TD]MAEU
[/TD]
[TD="align: right"]750
[/TD]
[/TR]
[TR]
[TD]AFRICA
[/TD]
[TD]SEHEL
[/TD]
[TD]MAEU
[/TD]
[TD="align: right"]900
[/TD]
[/TR]
[TR]
[TD]AFRICA
[/TD]
[TD]SENRK
[/TD]
[TD]MAEU
[/TD]
[TD="align: right"]700
[/TD]
[/TR]
[TR]
[TD]AFRICA
[/TD]
[TD]SEGOT
[/TD]
[TD]NYKU
[/TD]
[TD="align: right"]775
[/TD]
[/TR]
[TR]
[TD]AFRICA
[/TD]
[TD]SEHEL
[/TD]
[TD]NYKU
[/TD]
[TD="align: right"]950
[/TD]
[/TR]
[TR]
[TD]AFRICA
[/TD]
[TD]SENRK
[/TD]
[TD]NYKU
[/TD]
[TD="align: right"]650
[/TD]
[/TR]
[TR]
[TD]AFRICA
[/TD]
[TD]SEGOT
[/TD]
[TD]OOLU
[/TD]
[TD="align: right"]800
[/TD]
[/TR]
[TR]
[TD]AFRICA
[/TD]
[TD]SEHEL
[/TD]
[TD]OOLU
[/TD]
[TD="align: right"]950
[/TD]
[/TR]
[TR]
[TD]AFRICA
[/TD]
[TD]SENRK
[/TD]
[TD]OOLU
[/TD]
[TD="align: right"]950
[/TD]
[/TR]
[TR]
[TD]AMNO
[/TD]
[TD]SEGOT
[/TD]
[TD]HPLU
[/TD]
[TD="align: right"]500
[/TD]
[/TR]
[TR]
[TD]AMNO
[/TD]
[TD]SEHEL
[/TD]
[TD]HPLU
[/TD]
[TD="align: right"]600
[/TD]
[/TR]
[TR]
[TD]AMNO
[/TD]
[TD]SENRK
[/TD]
[TD]HPLU
[/TD]
[TD="align: right"]650
[/TD]
[/TR]
[TR]
[TD]AMNO
[/TD]
[TD]SEGOT
[/TD]
[TD]MAEU
[/TD]
[TD="align: right"]450
[/TD]
[/TR]
[TR]
[TD]AMNO
[/TD]
[TD]SEHEL
[/TD]
[TD]MAEU
[/TD]
[TD="align: right"]500
[/TD]
[/TR]
[TR]
[TD]AMNO
[/TD]
[TD]SENRK
[/TD]
[TD]MAEU
[/TD]
[TD="align: right"]550
[/TD]
[/TR]
[TR]
[TD]AMNO
[/TD]
[TD]SEGOT
[/TD]
[TD]NYKU
[/TD]
[TD="align: right"]550
[/TD]
[/TR]
[TR]
[TD]AMNO
[/TD]
[TD]SEHEL
[/TD]
[TD]NYKU
[/TD]
[TD="align: right"]700
[/TD]
[/TR]
[TR]
[TD]AMNO
[/TD]
[TD]SENRK
[/TD]
[TD]NYKU
[/TD]
[TD="align: right"]500
[/TD]
[/TR]
[TR]
[TD]LATAM
[/TD]
[TD]SEGOT
[/TD]
[TD]OOLU
[/TD]
[TD="align: right"]900
[/TD]
[/TR]
[TR]
[TD]LATAM
[/TD]
[TD]SEHEL
[/TD]
[TD]OOLU
[/TD]
[TD="align: right"]1100
[/TD]
[/TR]
[TR]
[TD]LATAM
[/TD]
[TD]SENRK
[/TD]
[TD]OOLU
[/TD]
[TD="align: right"]1100
[/TD]
[/TR]
[TR]
[TD]LATAM
[/TD]
[TD]SEGOT
[/TD]
[TD]MAEU
[/TD]
[TD="align: right"]1100
[/TD]
[/TR]
[TR]
[TD]LATAM
[/TD]
[TD]SEHEL
[/TD]
[TD]MAEU
[/TD]
[TD="align: right"]1300
[/TD]
[/TR]
[TR]
[TD]LATAM
[/TD]
[TD]SENRK
[/TD]
[TD]MAEU
[/TD]
[TD="align: right"]1300
[/TD]
[/TR]
[TR]
[TD]LATAM
[/TD]
[TD]SEGOT
[/TD]
[TD]COSU
[/TD]
[TD="align: right"]800
[/TD]
[/TR]
[TR]
[TD]LATAM
[/TD]
[TD]SEHEL
[/TD]
[TD]COSU
[/TD]
[TD="align: right"]1000
[/TD]
[/TR]
[TR]
[TD]LATAM
[/TD]
[TD]SENRK
[/TD]
[TD]COSU
[/TD]
[TD="align: right"]1000
[/TD]
[/TR]
[TR]
[TD]SPAC
[/TD]
[TD]SEGOT
[/TD]
[TD]HPLU
[/TD]
[TD="align: right"]1000
[/TD]
[/TR]
[TR]
[TD]SPAC
[/TD]
[TD]SEHEL
[/TD]
[TD]HPLU
[/TD]
[TD="align: right"]1100
[/TD]
[/TR]
[TR]
[TD]SPAC
[/TD]
[TD]SENRK
[/TD]
[TD]HPLU
[/TD]
[TD="align: right"]1100
[/TD]
[/TR]
[TR]
[TD]SPAC
[/TD]
[TD]SEGOT
[/TD]
[TD]COSU
[/TD]
[TD="align: right"]800
[/TD]
[/TR]
[TR]
[TD]SPAC
[/TD]
[TD]SEHEL
[/TD]
[TD]COSU
[/TD]
[TD="align: right"]700
[/TD]
[/TR]
[TR]
[TD]SPAC
[/TD]
[TD]SENRK
[/TD]
[TD]COSU
[/TD]
[TD="align: right"]700
[/TD]
[/TR]
[TR]
[TD]SPAC
[/TD]
[TD]SEGOT
[/TD]
[TD]MAEU
[/TD]
[TD="align: right"]900
[/TD]
[/TR]
[TR]
[TD]SPAC
[/TD]
[TD]SEHEL
[/TD]
[TD]MAEU
[/TD]
[TD="align: right"]1200
[/TD]
[/TR]
[TR]
[TD]SPAC
[/TD]
[TD]SENRK
[/TD]
[TD]MAEU
[/TD]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D]
[TD]OOLU
[/TD]
[TD]MAEU
[/TD]
[TD] -
[/TD]
[/TR]
[TR]
[TD]SPAC
[/TD]
[TD]SEGOT
[/TD]
[TD]COSU
[/TD]
[TD]MAEU
[/TD]
[TD]HPLU
[/TD]
[TD] -
[/TD]
[/TR]
[TR]
[TD]SPAC
[/TD]
[TD]SEHEL
[/TD]
[TD]COSU
[/TD]
[TD]HPLU
[/TD]
[TD]MAEU
[/TD]
[TD] -
[/TD]
[/TR]
[TR]
[TD]SPAC
[/TD]
[TD]SENRK
[/TD]
[TD]COSU
[/TD]
[TD]HPLU
[/TD]
[TD]MAEU
[/TD]
[TD] -
[/TD]
[/TR]
</tbody>[/TABLE]


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

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
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,224,893
Messages
6,181,617
Members
453,057
Latest member
LE102024

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