Forum Discussion
create new groups from existing table
- 6 years ago
Hello adavid999
you can try to add a new column with the new region name
Group by this column, applying exactly the measures you want and after that combining both tables. Here the code for a short example
let Source = #table ( {"Region","%","resp"}, { {"x","5","2"}, {"y","10","3"}, {"y","15","4"} } ), #"Changed Type" = Table.TransformColumnTypes(Source,{{"%", type number}, {"resp", type number}}), #"Added Custom" = Table.AddColumn(Table.RemoveColumns(#"Changed Type", "Region"), "Region", each "group xyy"), #"Grouped Rows" = Table.Group(#"Added Custom", {"Region"}, {{"%", each List.Average([#"%"]), type number}, {"resp", each List.Sum([resp]), type number}}), Combine = Table.Combine({#"Changed Type", #"Grouped Rows"}) in CombineCopy 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 adavid999
you can try to add a new column with the new region name
Group by this column, applying exactly the measures you want and after that combining both tables. Here the code for a short example
let
Source = #table
(
{"Region","%","resp"},
{
{"x","5","2"}, {"y","10","3"}, {"y","15","4"}
}
),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"%", type number}, {"resp", type number}}),
#"Added Custom" = Table.AddColumn(Table.RemoveColumns(#"Changed Type", "Region"), "Region", each "group xyy"),
#"Grouped Rows" = Table.Group(#"Added Custom", {"Region"}, {{"%", each List.Average([#"%"]), type number}, {"resp", each List.Sum([resp]), type number}}),
Combine = Table.Combine({#"Changed Type", #"Grouped Rows"})
in
Combine
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