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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
EaglesTony
Helper V
Helper V

Need help grouping and averaging

hi,

 

I have a table as follows(btw name is irrevelant I think in this example, so thinking of removing that column):

 

Project     Name       Point

ABC         Test1          30

ABC         Test2          10

ABC         Test3          10

ABC         Test4          20

ABC         Test5          30

DEF          Test1          20

GHI          Test1         10

GHI          Test2          20

 

I want in Powerquery M to group them by Project and get an average, so I have the following result:

 

(ABC would be 100/5 rows, DEF would be 20/1 Row, GHI would be 30/2

Project     Avg

ABC         20

DEF          20

GHI          15

 

Thanks!

2 REPLIES 2
Kmcdonald
Helper III
Helper III

Hi EaglesTony,

 

I got the desired result by a simple group by and using an average aggregation.

 

This is how I started:

 

Kmcdonald_0-1682211296318.png

Then from the "Transform" tab I chose "Group by".

 

Kmcdonald_1-1682211341913.png

 

Then I chose the criteria below.

 

Kmcdonald_2-1682211385429.png

 

Then I got the final result below.

 

Kmcdonald_3-1682211423429.png

 

 

 

Vijay_A_Verma
Super User
Super User

Use a simple Group By

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WcnRyVtJRCkktLjEE0sYGSrE6yIJGQNoQXdAYm6AJkDZCFzRFmOni6oZkEVSlu4cnkqAhuqARVGUsAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Project = _t, Name = _t, Point = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Project", type text}, {"Name", type text}, {"Point", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Project"}, {{"Avg", each List.Average([Point]), type nullable text}})
in
    #"Grouped Rows"

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors