Search code examples
excelexcel-formulaoffice365ms-officedata-cleaning

Is there a way to get data of the first 3 rows of each group of rows in Excel?


I have data consisting of over 5000 rows in Excel. I want to get the first 3 rows from each group into a different sheet. If that is not possible, I would like to delete all rows except the first 3 rows of each group of data.

PS: I have searched for this question on multiple forums, and I did not get the answer. If you think this is a duplicate question, lacking the technical terms, please share the links to the discussions politely.

Here is a screenshot of the data in Excel: enter image description here


Solution

  • Another way of doing it in Excel 365:

    =LET(seq,SEQUENCE(ROWS(A2:A21)),FILTER(A2:E21,seq-XLOOKUP(A2:A21,A2:A21,seq)<=2))
    

    enter image description here