Forum Discussion
List columns simultaneous expansion
- 5 years ago
Hello Anonymous
check out this solution. It adds a new column to your data, creating a table out of your year and count column. After that the list-columns are deleted and the new table expanded
let Source = #table({"Ref", "Year", "Count"}, {{"181", {"2019", "2020"}, {"50000", "34000"}},{"182", {"2019", "2020"}, {"50000000", "34000000"}}}), AddTable = Table.AddColumn ( Source, "TableYearCount", each Table.FromColumns({_[Year], _[Count]}, {"Year","Count"}), type table ), RemoveYearCount = Table.RemoveColumns(AddTable,{"Year", "Count"}), ExpandYearCount = Table.ExpandTableColumn(RemoveYearCount, "TableYearCount", {"Year", "Count"}, {"Year", "Count"}) in ExpandYearCountCopy paste this code to the advanced editor in a new blank query to see how the solution works.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy
Hello Anonymous
check out this solution. It adds a new column to your data, creating a table out of your year and count column. After that the list-columns are deleted and the new table expanded
let
Source = #table({"Ref", "Year", "Count"}, {{"181", {"2019", "2020"}, {"50000", "34000"}},{"182", {"2019", "2020"}, {"50000000", "34000000"}}}),
AddTable = Table.AddColumn
(
Source,
"TableYearCount",
each Table.FromColumns({_[Year], _[Count]}, {"Year","Count"}),
type table
),
RemoveYearCount = Table.RemoveColumns(AddTable,{"Year", "Count"}),
ExpandYearCount = Table.ExpandTableColumn(RemoveYearCount, "TableYearCount", {"Year", "Count"}, {"Year", "Count"})
in
ExpandYearCount
Copy paste this code to the advanced editor in a new blank query to see how the solution works.
If this post helps or solves your problem, please mark it as solution (to help other users find useful content and to acknowledge the work of users that helped you)
Kudoes are nice too
Have fun
Jimmy
Thank you Jimmy,
This worked just fine!!!
The code I used is
= Table.AddColumn(#"Renamed Columns", "TableYearCount",each Table.FromColumns({_[Year],_[Count]},{"Year","Count"}),type table)
, where #"Renamed Columns" is the previous applied step.
It also took me a while to figure out that in order for this to work, the lists must not be expanded.
Kind regards,
George