Forum Discussion
lankyman22
Nov 06, 2024Copper Contributor
How to Append Tables with Different Column Order with Automatic Refresh
There are 4 tables that I am wanting to append together, though their columns aren't in the same order (even some with more columns than other) that need to be in one table and have the ability to au...
Lorenzo
Nov 07, 2024Silver Contributor
Provided you run 365 a LAMBDA based option is attached:
You define the order in which your table columns should be appended + the name of your tables (first 2 lines of the following LET expression):
=LET(
expected_cols_order, {"A","B","C","D"},
input_tables, {"Table1","Table2","Table3","Table4"},
stack_table,
LAMBDA(seed,table_name,
LET(
table, INDIRECT( table_name & "[#All]" ),
VSTACK(seed,
CHOOSECOLS( DROP( table, 1 ), SORT( XMATCH( CHOOSEROWS( table, 1 ), expected_cols_order ),,, TRUE ) )
)
)
),
stacked_tables, REDUCE(expected_cols_order, input_tables, stack_table ),
IF( ISBLANK( stacked_tables ), "", stacked_tables )
)
(this can be put as a Named LAMBDA in the Name Manager instead of the LET expression on the sheet)
- LorenzoNov 16, 2024Silver Contributor
The 365 option you've been given could help other users, assuming the the issue is marked as Solved...