google-sheetsmaxgoogle-sheets-formulaminmaxifs

How do I find the maximum and minimum against multiple string criteria (Google Sheets)?


I'm using imported data from a webpage into Google Sheets (using ImportJSON). From the table below, I want to find the maximum and minimum number in column "sell price min". In theory, data only counts if it's from the list of "Valid Cities" within Column 1 (e.g prices from "Arthurs Rest" won't count towards the function, but prices from "Bridgewatch" and "Lymhurst" will).

enter image description here

The formulae I tried with are:

=MINIFS(E:E,D:D,{A5:A10})
=MAXIFS(E:E,D:D,{A5:A10})

Neither of these function works they way it was intended. It simply displays the sell price of the first city (Caerleon). I've tested this by mixing the order of "Valid Cities" up, it's often the very first city in the list that the formula seems to care about. I want to be able to find the max/min that are valid cities. Thanks


Solution

  • I think that MAXIFS and MINIFS can only be used when checking against a single criteria such as ">25" as opposed to a range.

    Also note that where you have E:E and D:D in your formula, you probably want E4:E and D4:D. You are not interested in the values entered into the first three rows.

    One way to accomplish what you want is to use a helper column (say column G) with the following formula in cells G4-G13 (N.B. you will have to change D4 and E4 in each corresponding row.

    =IFERROR(IF(MATCH(D4,$A$5:$A$10, 0), E4))
    

    This formula returns Sell Price Min if the city is in the list of valid cities or if not.

    Then simply use MIN(G4:G) and MAX(G4:G) to find the min and max for that column.

    There will be a better solution using array functions but the above method will hopefully point you in the right direction.