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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
abedkhooli
Frequent Visitor

Aggregate columns from one table into rows of another table

PBIQ-Eggs.png

I have dynamic data in a few columns in Table2 (see image). In Table 1 (created manually - enter data), each row represents one of the columns in Table 2. I need to replace the placeholders in the 3rd column of Table 1 with the average of the values in the indicated columns from Table 2 (the two tables are not related). Tried conditional column but it does not accept formulas in the value field. Thought about Table.FromRows and got an error (not sure if formula or reference related). Any ideas? Hopefully it is simple, not an expert!

1 ACCEPTED SOLUTION
MarcelBeug
Community Champion
Community Champion

Easiest is to add the averages as a new column.

So, if you delete the column with placeholders from Table1, you can add it in your query on the tab "Add Column", option "Custom Column" with name AvNO2

and formula

= List.Average(Table.Column(Table2,[EggName]&"NO2"))

 

or, if you need to catch any errors:

 

= try List.Average(Table.Column(Table2,[EggName]&"NO2")) otherwise null

 

 

Specializing in Power Query Formula Language (M)

View solution in original post

3 REPLIES 3
MarcelBeug
Community Champion
Community Champion

Easiest is to add the averages as a new column.

So, if you delete the column with placeholders from Table1, you can add it in your query on the tab "Add Column", option "Custom Column" with name AvNO2

and formula

= List.Average(Table.Column(Table2,[EggName]&"NO2"))

 

or, if you need to catch any errors:

 

= try List.Average(Table.Column(Table2,[EggName]&"NO2")) otherwise null

 

 

Specializing in Power Query Formula Language (M)

Thank you @MarcelBeug - this works very well.

Although naming was not intended for calculation purposes, your formula made it elegant and simple. Will add my other columns in the same way.

Thank you, worked for me!

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.