I have a Google sheet query, which works fine, but I need the count function to count the cell only if it is distinct (unique value). I have a sheet, where Col2 can have repeated IDs, e.g. ID01, ID02, ID01. I need to count ID01 only once, even if the sheet has multiple rows for it. Here is my google query:
QUERY(IMPORTRANGE("sheetURL/","sheetname!A1:Z50"), "SELECT count(Col2) where Col1='"&$D$2&"' and Col3 contains 'xyz'")
In SQL, there is distinct where I can use count(distinct Col2) but it does not work in Google sheets.Is there any way where I can count only distinct values of Col2 in my query?
Note that I need distinct cell (Col2), not distinct row or record. UNIQUE(QUERY(...)) does not seem the right thing for me, as UNIQUE will return unique rows (not cells as I want).
