Based on the data below, I would like to get the latest date for each category where the type must not be "0"
Google Sheets – How to Get Latest Data Grouped by Category Excluding Type 0
google sheets
Related Topic
- Google-sheets – Get the latest specific date prior to today
- Google-sheets – Tally duration, client, client category in each Google sheets Timesheet
- Google-sheets – find the number of add-ons for each category in the Google Sheets Add-ons store
- Google-sheets – Copying the latest data from an accumulating list to another sheet
- Google Sheets – How to Filter Highest Value for Each Date Based on Criteria
- Google-sheets – How to use a checkbox to choose to add the value or not in total
Best Answer
Assuming these things to be true:
Use this formula:
=ArrayFormula(IFERROR(VLOOKUP(UNIQUE(A:A),QUERY(IF(C:C<>0,A:C,""),"Select * Order by Col2 Desc"),{1, 2, 3},FALSE),""))
How it works:
Working from the inside out...
IF(C:C<>0,A:C,"")
First create a limited range of only those rows in A:C that don't have a zero value as "TYPE" (Column C).
QUERY(___,"Select * Order by Col2 Desc")
QUERY this range in reverse (now all "most recent dates" will be at the top.
VLOOKUP(UNIQUE(A:A),___,"Select * Order by Col2 Desc"),{1, 2, 3},FALSE)
Look up each unique value in A:A (in your example, there are only 4: A, B, C and null). Use the upsidedown QUERY we created as the search range. Return the array formed of all three columns ({1, 2, 3}, in other words, all data per matching row). The categories are not guaranteed in any order, so we use FALSE at the end.
Since VLOOKUP stops when it finds a match, and the QUERY range is upside-down, the first match will always be the one with the most recent date.
IFERROR(___,"")
If there is no match (which will only happen with the UNIQUE value null), leave that final row in the array null as well.