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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Create a table from existing table using Average function

I have the exising data in the below format.

niharikatomar_1-1692808289641.png

I want to create a new table  (not a visualization)  with average of these columns which should look somthing like this:

 

niharikatomar_2-1692808570888.png

 

Any help is appreciated.

 

Thank you

 

5 REPLIES 5
Vijay_A_Verma
Super User
Super User

A Table.Group is what you need. See the sample code below

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("bZG7DsMgDEX/hTmD8du/UalTlDFDlyx9fH/TFJASkBgQ5+Bry/Ocbutn3d5rmhKSAWXab/vJnIOO+zKdJBMFwSKJEPlAUhXBJpECDCQmM+EiOUkMK5kiapHUFaWXDo8BvCWikg4kZnatAwIh4UAy08DalnDwSGJh8CopcfZRTzmYSk9BCHI49+3xev5eaifBbfDKMuQyszv0EKH8/C/iVBXqR+iqhhUWKld2Cg3sWc20uLIWmfc1X1mNNOuQekGcluUL", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Variables = _t, #"Control Pre" = _t, #"Control Post" = _t, #"Test Pre" = _t, #"Test Post" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Variables", type text}, {"Control Pre", Int64.Type}, {"Control Post", Int64.Type}, {"Test Pre", Int64.Type}, {"Test Post", Int64.Type}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Variables"}, {{"Avg Control Pre", each List.Average([Control Pre]), type nullable number}, {"Avg Control Post", each List.Average([Control Post]), type nullable number}, {"Avg Test Pre", each List.Average([Test Pre]), type nullable number}, {"Avg Test Post", each List.Average([Test Post]), type nullable number}})
in
    #"Grouped Rows"
Anonymous
Not applicable

I currently have the query with changed type as attched below:

 

niharikatomar_1-1692821022378.png

Will I have to change it

Insert a new step and paste this code in formula bar

= Table.Group(#"Changed Type", {"Variable"}, {{"Avg Control Pre", each List.Average([Control Pre]), type nullable number}, {"Avg Control Post", each List.Average([Control Post]), type nullable number}, {"Avg Test Pre", each List.Average([Test Pre]), type nullable number}, {"Avg Test Post", each List.Average([Test Post]), type nullable number}})
Anonymous
Not applicable

niharikatomar_0-1692820914281.png

I see this error, can you help?

Hi @Anonymous ,

 

you need to change the source with your source to make that work

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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 Solution Authors