Forum Discussion
How to simplify M code for multiple actions, each on particular columns within nested tables
I'm sure that you could use Table.TransformColumns instead of Add Column, which would give you a single step for filling up, and eliminate the need for the Remove Column steps. You can also add the MissingField.Ignore parameter as the optional parameter in Table.TransformColumns, so that if any particular columns are not present, they will be ignored by the M script.
--Nate
Hi,
sorry for the late reply, but my solution back then was
FillDown_columns_in_nested_tables = Table.Group(
SortedRows,
{"Node", "Variant"},
{{"Grouped", each Table.FillDown(_, {"Col ABC", "Col 123", "Col XYZ"}), type table}}
),
RemovedOtherColumns = Table.SelectColumns(
FillDown_columns_in_nested_tables,
{"Grouped"}
),
Expand_dyn = Table.ExpandTableColumn(
RemovedOtherColumns,
"Grouped",
Table.ColumnNames(RemovedOtherColumns[Grouped]{0}),
Table.ColumnNames(RemovedOtherColumns[Grouped]{0})
),
At least this shortened all a bit and of course - as you suggested - a NameOfListOfPossibleColumns could be used instead of writing each single column name. Perhaps I once will try to get it done be Table.TransformColumns.
Thank you.