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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Antoinette123
Helper I
Helper I

Power Query: after combining 2 tables got something strange

I have a column "Name", in which each value is repeated twice. And each value has its own share (input data). I need to calculate the average share among the first occurrence of values in the first column, and the average for the second occurrence, for each subgroup (the subgroups are distinguished by the first part of the name: like input car 1, car 1, car 2, car 2, bike 1, bike 1, bike 2, bike 2, etc (word + number). An example is shown in the figure. I already created an occurrence index.

   
OwnerNameShareIndexwhat I need ->OwnerNameShareIndexAverage share
BobCar 10,451 BobCar 10,451(0,45+0,4)/2
BobCar 10,552 BobCar 10,552(0,55+0,6)/2
BobCar 20,41 BobCar 20,41(0,45+0,4)/2
BobCar 20,62 BobCar 20,62(0,55+0,6)/2
AlexBike 10,31 AlexBike 10,31(0,3+0,2)/2
AlexBike 10,72 AlexBike 10,72(0,7+0,8)/2
AlexBike 20,21 AlexBike 20,21(0,3+0,2)/2
AlexBike 20,82 AlexBike 20,82(0,7+0,8)/2

1000038474.png

 To solve the task, I used "group by" and most of my columns disappeared in the new table. And when I try to merge the tables, I get strange results with many rows being repeated million times.

1 ACCEPTED SOLUTION

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcspPUtJRck4sUjAE0gY6JqZAylApVgdTyhQkZYQmZQTRhUUTRMYMrscxJ7UCyHHKzE6FGmgM14UpZ45VH8RMI6z6IHIWEH2xAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Owner = _t, Name = _t, Share = _t, Index = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Share", type number}},"de"),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Average Share", (k)=> List.Average(Table.SelectRows(#"Changed Type", each [Owner]=k[Owner] and [Index]=k[Index])[Share]),type number)
in
    #"Added Custom"

How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done". Once you examined the code, replace the Source step with your own source.

View solution in original post

6 REPLIES 6
Anonymous
Not applicable

Looks like you should be grouping by owner and index. From there, I'm not sure if you want the result to be the result of the calculation (average of the shares of each group) or the actual text

(0,45+0,4)/2

But if you are trying to end up with the actual average, you need to split the share column by the comma and then do your group by owner and index, and then aggregate by average, which seems to be the best way to do this.

 

--Nate

lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information or anything not related to the issue or question.

If you are unsure how to upload data please refer to https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Hi! How can I include the file or send it? I couldn't find such option in the settings of the post

I've just added the table to the post

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcspPUtJRck4sUjAE0gY6JqZAylApVgdTyhQkZYQmZQTRhUUTRMYMrscxJ7UCyHHKzE6FGmgM14UpZ45VH8RMI6z6IHIWEH2xAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Owner = _t, Name = _t, Share = _t, Index = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Share", type number}},"de"),
    #"Added Custom" = Table.AddColumn(#"Changed Type", "Average Share", (k)=> List.Average(Table.SelectRows(#"Changed Type", each [Owner]=k[Owner] and [Index]=k[Index])[Share]),type number)
in
    #"Added Custom"

How to use this code: Create a new Blank Query. Click on "Advanced Editor". Replace the code in the window with the code provided here. Click "Done". Once you examined the code, replace the Source step with your own source.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Kudoed Authors