Filtering duplicates into different routes

Hello, Makers!

I have already searched for help here but got no answer. I will try to describe the problem in another way now.

I have a Google Sheet Search Row module, where I get an output of 1-4 rows.

Some of the rows have the same column A and B values, but different (or the same) price (column E).

These are duplicates. All I need to do is to send them to 1st route, and unique ones to the 2nd.

Let`s imagine I have the output as in the screenshot above. There are 2 duplicates (jaguar) and 1 unique one (original used part). We have to send duplicates to one route (and then I will choose the one with the max price value), and unique ones to another.

I create a Telegram bot, so info will be used for the message. The input is a message, that User sends (part number in column A).

We have been thinking about deduplicate() or distinct() functions, but not sure how to use them in this situation and how to use these variables as an array for these functions. Also maybe we should use something like dynamic filtering or creating variables out of B column, but we have about 40-50 Column B values, so it would be pretty challenging.

Please, any advice could be very helpful for us.

Hi @alinam1,
Try using the “advanced search action” of the Google Sheets module. There you can create a SQL query that returns the rows without duplicate values as well as another SQL query for rows with duplicate values.

The SQL query will be along the lines of the following (You will need to work on it a bit to create 2 separate SQL queries to suit your 2 situations for rows without duplicate values as well as rows with duplicate values)

select A,B, COUNT(A) group by A,B


@Harsh thank you very much! It was a bit harder to implement, but the idea was right. You are a hero! Thank you for your help and wish you all the best :pray: :handshake: :handshake: