SOLVED

vlookup for a vertical MAX returning name

Copper Contributor

hi, 

 

CUSTOMER CODESALESSALES ADVISOR
1234563400000CARLOTTA
123456300000MERCO
12345660000CATERINA
12345660000CATERINA
12345623500MATTEO 
12345623500MATTEO 
9876543436CATERINA
987654223344MERCO
9876544567CARLOTTA
9876543456MATTEO 

hi everyone, 

Given the 'CUSTOMER CODE' with multiple 'SALES' I would like to return the 'SALES ADVISOR' with the best/max 'SALES' value.

i.e. given '987654' -----> 'MERCO'

 

I tried different vlookup with no success.

 

Thanks in advance

 

Matteo

 

 

8 Replies
best response confirmed by allyreckerman (Microsoft)
Solution

@MacTeo84 

With the customer code in E2, the maximum sales amount in F1 is given by

 

=MAXIFS($B$2:$B$11,$A$2:$A$11,E2)

 

and the corresponding sales advisor in G1 is given by

 

=INDEX($C$2:$C$11,MATCH(1,INDEX(($A$2:$A$11=E2)*($B$2:$B$11=F2),,),0))

 

These formulas can be filled down, if required.

 

S0358.png

@Hans Vogelaar 

 

Thank you very much!!!!

@MacTeo84 

@Hans Vogelaar 's solution is probably simpler!

image.png

@MacTeo84 And one more. This time with Power Query, as long as you are not on a Mac.

Screenshot 2021-05-02 at 12.28.26.png

Add sales data to the blue table and refresh the green one to update the summary.

File attached.

Irony, of course I'm on Mac... :), but I'll try to apply it on the PC I have at work!!!
Thank you very much!!!!

@MacTeo84 Actually, you can add data to the blue table and refresh the green one in this file on a Mac, but you can't edit the queries. You can't even look at them, which makes it quite useless.

@Riny_van_Eekelen 

As variant

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Grouped Rows" = Table.Group(
        Source, {"CUSTOMER CODE"},
        {{"Count", each  Table.Sort(_,{{"SALES", Order.Descending}}){0} }}
    ),
    #"Expanded Count" = Table.ExpandRecordColumn(
        #"Grouped Rows",
        "Count",
        {"SALES", "SALES ADVISOR"}, {"SALES", "SALES ADVISOR"}
    )
in
    #"Expanded Count"
1 best response

Accepted Solutions
best response confirmed by allyreckerman (Microsoft)
Solution

@MacTeo84 

With the customer code in E2, the maximum sales amount in F1 is given by

 

=MAXIFS($B$2:$B$11,$A$2:$A$11,E2)

 

and the corresponding sales advisor in G1 is given by

 

=INDEX($C$2:$C$11,MATCH(1,INDEX(($A$2:$A$11=E2)*($B$2:$B$11=F2),,),0))

 

These formulas can be filled down, if required.

 

S0358.png

View solution in original post