Search code examples
google-sheetsfilterfindtransposeflatten

Google Sheets - transpose column data in groups into rows


I am trying to transpose data from column A to single rows. The original data has 3 rows for each name. But there could be either 1 or several jobs for each day. Each day needs to be treated separately, but this maybe best handled by manually adding at the beginning of each day.

This is for a fortnightly timesheet, therefore the number of rows in unpredictable.

The 1st image is my original data. the 2nd is the desired end result. enter image description here

The data is to transposed to any blank rows in columns b, c, d, e, as long as there are no blank rows, I can then reference them with my formulas. to place the information into the appropriate cells within the timesheet. I already have working formulas to do this.

the transpose section is what I need help with

enter image description here

Here is a link to my file https://docs.google.com/spreadsheets/d/1PhuFXDB2H1c9ua6szjhJEgJR91yXHhZAmn_2UGOBvIo/edit?usp=sharing


Solution

  • try:

    =ARRAYFORMULA({QUERY(IF(REGEXMATCH(A12:A, "\d+:\d+.*"), VLOOKUP(ROW(A12:A), 
     IF(IF(IFERROR(RIGHT(A12:A, 4)*1)>2000, A12:A, )<>"", {ROW(A12:A), 
     IF(IFERROR(RIGHT(A12:A, 4)*1)>2000, A12:A, )}), 2, 1), ), "where Col1 is not null"),
     QUERY(IF((IFERROR(RIGHT(A12:A, 4)*1)>2000)+(REGEXMATCH(A12:A, "\d+:\d+.*")),, A12:A), 
     "where Col1 is not null skipping 2"), 
     QUERY(QUERY(IF((IFERROR(RIGHT(A12:A, 4)*1)>2000)+(REGEXMATCH(A12:A, "\d+:\d+.*")),, A12:A), 
     "where Col1 is not null offset 1", 0), "skipping 2"), 
     FILTER(A12:A, REGEXMATCH(A12:A, "\d+:\d+.*"))})
    

    enter image description here