Forum Discussion
M001
2 years agoHelper I
How to apply List for Dynamics Column Names in subsequence steps
Hi there, My last 3 columns 2024, 2025 and 2026 always change from time to time, as it represents year of my sales that I want to track, therefore I created a list (I named it as Years) for these...
- 2 years ago
If it is only the last three columns that need to have dynamic names, you can set the data types for all the columns by creating a list similar to:
#"Types List" = {{"Region", type text}, {"Country", type text}, {"Item", type text}, {"Price", Currency.Type}, {"Color", type text}} & List.Transform(List.LastN(Table.ColumnNames(#"Promoted Headers"),3), each {_, Int64.Type}),Then you can use it in the Transform.ColumnTypes function like:
#"Promoted Headers" = ..., #"Types List" = {{"Region", type text}, {"Country", type text}, {"Item", type text}, {"Price", Currency.Type}, {"Color", type text}} & List.Transform(List.LastN(Table.ColumnNames(#"Promoted Headers"),3), each {_, Int64.Type}), #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers", #"Types List") in #"Changed Type"
ronrsnfld
2 years agoSuper User
If it is only the last three columns that need to have dynamic names, you can set the data types for all the columns by creating a list similar to:
#"Types List" = {{"Region", type text}, {"Country", type text}, {"Item", type text}, {"Price", Currency.Type}, {"Color", type text}}
& List.Transform(List.LastN(Table.ColumnNames(#"Promoted Headers"),3), each {_, Int64.Type}),
Then you can use it in the Transform.ColumnTypes function like:
#"Promoted Headers" = ...,
#"Types List" = {{"Region", type text}, {"Country", type text}, {"Item", type text}, {"Price", Currency.Type}, {"Color", type text}}
& List.Transform(List.LastN(Table.ColumnNames(#"Promoted Headers"),3), each {_, Int64.Type}),
#"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers", #"Types List")
in
#"Changed Type"- M0012 years agoHelper I
Hi Ron,
Thank you so much and this is exactly what I was confused about. In fact, I have found a similar solution here
https://goodly.co.in/dynamic-data-types-power-query/
Regards,
M