Forum Discussion
Looping through columns in table
- 4 years ago
Hi,
I've been testing around, after a friend told me a way to incoorporate loops in M and this is what I found myself.
MergedColumns = List.Accumulate(
{7..40}, #"Changed Type",(state,current)
=> Table.CombineColumns(state,
{"Column" & Number.ToText(current*2-1), "Column" & Number.ToText(current*2) },
Combiner.CombineTextByDelimiter("||",QuoteStyle.None),
"Column"& Number.ToText(current*2-1))
)
And this works. It merges all columns between number 13 and 80 and gives them correct names.
Cheers
Meindert
Hi,
I've been testing around, after a friend told me a way to incoorporate loops in M and this is what I found myself.
MergedColumns = List.Accumulate(
{7..40}, #"Changed Type",(state,current)
=> Table.CombineColumns(state,
{"Column" & Number.ToText(current*2-1), "Column" & Number.ToText(current*2) },
Combiner.CombineTextByDelimiter("||",QuoteStyle.None),
"Column"& Number.ToText(current*2-1))
)
And this works. It merges all columns between number 13 and 80 and gives them correct names.
Cheers
Meindert