Forum Discussion

micyano's avatar
micyano
Copper Contributor
Nov 28, 2023

How to generate a table of data built up off of smaller parts?

Hello Excel Gurus   I can't even figure out how to ask this question so I'm hoping if you can look at the data set I'm working with, and how it should look after combining the information, someone ...
  • djclements's avatar
    djclements
    Nov 28, 2023

    michyano If I've understood you correctly, I think the error can be solved by filtering the data first, to exclude any blank rows / rows that contain all zeros.

     

    =LET(data, A2:E40,
    arr, FILTER(data, NOT(BYROW(data, LAMBDA(r, AND(r=0))))),
    DROP(REDUCE("", SEQUENCE(ROWS(arr)), LAMBDA(v,n, LET(
       acc, INDEX(arr, n, 4),
       top, SCAN(INDEX(arr, n, 2), IF(SEQUENCE(INDEX(arr, n, 5)), acc), LAMBDA(a,r, a+r)),
       name, INDEX(arr, n, 1),
       VSTACK(v, IFNA(HSTACK(name, top-acc, top), name))))), 1))

     

    As requested, the headers were also excluded in this example (data range starts at A2 instead of A1). An empty string was used as the initial_value for the REDUCE function, and the whole thing was wrapped in the DROP function to eliminate the first row from the results. Hopefully that works!

Resources