Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
adavid999
Helper V
Helper V

create new groups from existing table

Dear all,

I am working in power query/excel. Is it possible/uncomplicated to group some items in an existing external odata table into new categories so that any measures/displays pick up both new groups and individual elements? I.e. a new Region group as below xyz showing an average of % and a sum of resp?

Region%resp
x52
y103
y154
*new Group xyx109

 

Ideally I would not have to change any existing pivot tables/measures/displays. Please could you let me know how to do this, or point to a helpful resource?

 

Many thanks,

 

A

1 ACCEPTED SOLUTION
Jimmy801
Community Champion
Community Champion

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

View solution in original post

2 REPLIES 2
Jimmy801
Community Champion
Community Champion

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

Hi @Jimmy801 I think that would do it - so simple! Even a new column in the existing table should work shouldn't it?!

Thanks,

A

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors