XLOOK UP multiple criteria

Occasional Contributor


In sheet 2, I want a formula in column B that picks for the latest year in column C of the Data 1 sheet, a value in column B for a code in Column A of sheet 2, based on criteria in Data 1 sheet Column A. The code in sheet 2 is in  Column D Data 1 sheet and has been concatenated with column G to get what you see in Column A. For example, if I want all values for 25+ for CHL for the latest year available in Colum  C of the Data 1 sheet.

Thank you!

4 Replies

@Lycias Since you intend to use XLOOKUP, you also have access to the FILTER function. Combine that one with XLOOKUP and achieve what you need. The attached file contains your data but transformed into structured tables. Didn't really see the need to concatenate the Subgroup and Area ID, so got rid of that column. In stead, I added a column for the first three characters of the Area ID so that the matching to the Codes in Sheet2 becomes easier. But it isn't necessary either as you see from the alternative solution in Sheet2. Also deleted the text based value column in Sheet1. You can achieve the same number formatting by applying a custom format.


Finally, I added some Data Validation based on a list of all existing (unique) age categories. That saves you from having to re-type them in the formulae, should you want to change the selection criteria.


@Riny_van_Eekelen Thank you so much, a lifesaver. I see that the formula is picking the latest value (Time, in column A of sheet 1) for each country code. Which part of this formula is achieving this? I can follow the rest of the solution except this part. Thank you.
best response confirmed by Lycias (Occasional Contributor)

@Lycias The last optional argument  is set to -1, which means that the search is done "last-to-first", so from the bottom up. Since your data is sorted in ascending year order, it works.

Perfect, thank you so much!.