Home > Back-end >  Transform stacked tables of key value pairs to a single key value table dynamically
Transform stacked tables of key value pairs to a single key value table dynamically

Time:08-02

I want to dynamically convert stacked tables of key-value pairs into a single key-value table.
The input table has hundreds of key value pair tables stacked on top of each other. Every table has 3 columns.
enter image description here

I tried using a healper column with this formula, but it's not feasible in my case.

={ {"Key", "Value"}; { FLATTEN( FILTER(A2:C,D2:D="Key")), FLATTEN( FILTER(A2:C,D2:D="Value")) }}

enter image description here

CodePudding user response:

try:

={"Key", "Value"; FLATTEN(FILTER(A2:C, ISEVEN(ROW(A2:A)))), 
                  FLATTEN(FILTER(A2:C,  ISODD(ROW(A2:A))))}

enter image description here

or:

={"Key", "Value"; FLATTEN(QUERY(A2:C, "skipping 2", )), 
                  FLATTEN(QUERY(A3:C, "skipping 2", ))}

enter image description here

  • Related