How to Return Only Unique Rows using Query function
To return only unique rows using the Query function in Google Sheets, you can use the DISTINCT keyword in the SQL-like syntax of the Query function. This will only return unique rows and filter out the duplicate rows from the dataset.
Here's a step-by-step guide on how to use the Query function to return unique rows:
- Open your Google Sheet containing the data you want to filter.
- Click on an empty cell where you want to display the unique rows.
- Type the following formula:
=QUERY(range, "SELECT * DISTINCT")
Replace range
with the actual range of cells that you want to filter. For example, if your data is in cells A1:C10, you would type:
=QUERY(A1:C10, "SELECT * DISTINCT")
- Press Enter to apply the formula. Google Sheets will return the unique rows in the specified range.
Example
Let's suppose you have the following data in cells A1:B6:
Name Age
Alice 25
Bob 30
Alice 25
David 35
Eva 40
Bob 30
To return only the unique rows, you can use the Query function as follows:
- Click on an empty cell, for example, D1.
- Type the following formula:
=QUERY(A1:B6, "SELECT * DISTINCT")
- Press Enter.
The result in cells D1:E5 will be:
Name Age
Alice 25
Bob 30
David 35
Eva 40
Did you find this useful?