'IMPORTRANGE with MAX

I'm trying to IMPORTRANGE with MAX but just can't get it to work.

      Column A                 Column!M       Column!N
    1  apple                1   apple           5
    2  banana               2   apple           14
                            3   banana          10
                            4   apple           6
                            5   banana          8

Desired output:

  apple    14
  banana   10

This is what I have:

=MAX(importrange("url","Column!N1:N5"),importrange("url","Column!M1:M5")=A1:A2) 


Solution 1:[1]

Try the following:

Cell B1, enter the following:

=ARRAYFORMULA(MAX(if((importrange("SheetURL","SheetNameFromWhereYou’reImporting!M1:M5") = A1), (importrange("SheetURL","SheetNameFromWhereYou’reImporting!N1:N5")))))

Cell B2, enter the following:

=ARRAYFORMULA(MAX(if((importrange("SheetURL","SheetNameFromWhereYou’reImporting!M1:M5") = A2), (importrange("SheetURL","SheetNameFromWhereYou’reImporting!N1:N5")))))

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Lorena Gomez