Search code examples
google-sheetsgoogle-docs

How to get only a number of duplicates in Google sheet with Formula


I need help on Google Sheet regarding duplicates function.

I have data of Column A and B

  • Column A contains URL
  • Column B contains duplicate of the URL

I need the formula to sort the duplicates to have only for example 3 duplicates only.

So from this data:

enter image description here

To this data:

enter image description here

Using the google sheet function or formula.

All this time i try using manual and for big data resources would takes time.


Solution

  • below is a solution that populates the three results for each unique url in column B as a row.

    in cell C1:

    =UNIQUE(FILTER(B:B,B:B<>""))
    

    in cell D1:

    =BYROW(C:C,LAMBDA(x,TRANSPOSE(FLATTEN(QUERY(A:B,"select * where B='"&x&"' limit 3",0)))))