Forum Discussion
Dynamically generate column schema as record
- 1 year ago
Now I probably see what you want to achive. You want to replace this part of Table.Group. Is that correct?
If yes, you can just delete that part of Table.Group and use Table.Combine to preserve column types, like this:
let src=Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("lZBBCsMwDAT/4nMiVivLtvSO3EL+/4267aUlhWJdBIJhR3ueZUSUrRD0uXaFjjCprfX3te6IHfVAJDxJ0WaYU67tg60v1jkqhCugzYXlJOuNTuntm1RPjGQVRL+Tr//oGOai3WyF/aGpI9GTsytiRdOPmaNMhlhd1PzH3jT9UOQslE08FjVnzpN0ib6seWevBw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [id = _t, year = _t, amount = _t, ing_est = _t]), ct = Table.TransformColumnTypes(src,{{"id", Int64.Type}, {"year", Int64.Type}, {"amount", type number}, {"ing_est", type datetime}}, "en-US"), GroupedRows = Table.Group(ct, {"id"}, {{"ad", each _, type table}}), Combined = Table.Combine(GroupedRows[ad]) in Combined
The purpose is to create a function that can group any table with the dynamically generated schema of that table to be passed on to Table.Group.
Now I probably see what you want to achive. You want to replace this part of Table.Group. Is that correct?
If yes, you can just delete that part of Table.Group and use Table.Combine to preserve column types, like this:
let
src=Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("lZBBCsMwDAT/4nMiVivLtvSO3EL+/4267aUlhWJdBIJhR3ueZUSUrRD0uXaFjjCprfX3te6IHfVAJDxJ0WaYU67tg60v1jkqhCugzYXlJOuNTuntm1RPjGQVRL+Tr//oGOai3WyF/aGpI9GTsytiRdOPmaNMhlhd1PzH3jT9UOQslE08FjVnzpN0ib6seWevBw==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [id = _t, year = _t, amount = _t, ing_est = _t]),
ct = Table.TransformColumnTypes(src,{{"id", Int64.Type}, {"year", Int64.Type}, {"amount", type number}, {"ing_est", type datetime}}, "en-US"),
GroupedRows = Table.Group(ct, {"id"}, {{"ad", each _, type table}}),
Combined = Table.Combine(GroupedRows[ad])
in
Combined- smpa011 year agoCommunity Champion
Smashing !!! Any performance implication you may think of for a large table?
- dufoq31 year agoCommunity Champion
No, there shouldn't be any. Another advantage of Table.Combine is that it will expand each column of every table dynamicaly, besides if you Expand Columns via button - it will hardcode column names (but only for first table if I'm correct).