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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Anonymous
Not applicable

How to Calculate the average of rows (including blanks) from different tables

For example I have 3 different tables with same identifier.
How can I calculate the average of the rows(months)?

IDJanFebMar
125 
27 3
3566
4 12

 

IDAprMayJun
1393
2 45
31067
4374

 

IDJulAgoSep
1586
2610 
31049
4 95

 

I want to have the following output (the rows combined based on Unique ID to calculate Average (counting blanks)):

 

IDJanFebMarAprMayJunJulAgoSepAverage
169 4937355.111111
210 5 9636 4.333333
329101997346
4 19818 884.777778

 

 

thanks,

1 ACCEPTED SOLUTION
v-yueyunzh-msft
Community Support
Community Support

Hi , @Anonymous 

According to your description, i think it can be realized in Power Query Editor.

Here are the steps you can refer to :

(1)This is my test data which is the same as yours: 'Table1' and 'Table2' and 'Table3'

vyueyunzhmsft_0-1664503233692.png

(2)We can put this M language in "Advanced Editor":

let
    Source = Table.NestedJoin(Table1, {"ID"}, Table2, {"ID"}, "Sheet1", JoinKind.FullOuter),
    #"Merged Queries" = Table.NestedJoin(Source, {"ID"}, Table3, {"ID"}, "Sheet2", JoinKind.FullOuter),
    #"Expanded Sheet1" = Table.ExpandTableColumn(#"Merged Queries", "Sheet1", {"Apr", "May", "Jun"}, {"Apr", "May", "Jun"}),
    #"Expanded Sheet2" = Table.ExpandTableColumn(#"Expanded Sheet1", "Sheet2", {"Jul", "Ago", "Sep"}, {"Jul", "Ago", "Sep"}),
    #"Added Custom" = Table.AddColumn(#"Expanded Sheet2", "Average", (x)=> List.Sum(List.Skip(Record.ToList(x)))/List.Count(List.Skip(Record.ToList(x)))     )
in
    #"Added Custom"

(3)Then we can meet your need , the result is as follows:

vyueyunzhmsft_1-1664503309034.png

 

If you want to use dax to calculate the Average , you can unpivot the table like this:

vyueyunzhmsft_2-1664503402437.png

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

View solution in original post

6 REPLIES 6
v-yueyunzh-msft
Community Support
Community Support

Hi , @Anonymous 

According to your description, i think it can be realized in Power Query Editor.

Here are the steps you can refer to :

(1)This is my test data which is the same as yours: 'Table1' and 'Table2' and 'Table3'

vyueyunzhmsft_0-1664503233692.png

(2)We can put this M language in "Advanced Editor":

let
    Source = Table.NestedJoin(Table1, {"ID"}, Table2, {"ID"}, "Sheet1", JoinKind.FullOuter),
    #"Merged Queries" = Table.NestedJoin(Source, {"ID"}, Table3, {"ID"}, "Sheet2", JoinKind.FullOuter),
    #"Expanded Sheet1" = Table.ExpandTableColumn(#"Merged Queries", "Sheet1", {"Apr", "May", "Jun"}, {"Apr", "May", "Jun"}),
    #"Expanded Sheet2" = Table.ExpandTableColumn(#"Expanded Sheet1", "Sheet2", {"Jul", "Ago", "Sep"}, {"Jul", "Ago", "Sep"}),
    #"Added Custom" = Table.AddColumn(#"Expanded Sheet2", "Average", (x)=> List.Sum(List.Skip(Record.ToList(x)))/List.Count(List.Skip(Record.ToList(x)))     )
in
    #"Added Custom"

(3)Then we can meet your need , the result is as follows:

vyueyunzhmsft_1-1664503309034.png

 

If you want to use dax to calculate the Average , you can unpivot the table like this:

vyueyunzhmsft_2-1664503402437.png

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem.

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

onurbmiguel_
Power Participant
Power Participant

Hello, 

Can you sahre what will be the ouput that you want . 

In your model you have one fact table and one calendar table ? 

 

BR 

Bruno 

 


Best regards


Bruno Costa | Super User


 


Did I help you to answer your question? Accepted my post as a solution! Appreciate your Kudos!! 


Take a look at the blog: PBI Portugal 


 


Anonymous
Not applicable

I updated it 🙂
I have 3 tables in my model (actually I have more but these 3 related to this issue)

steveyx_0-1664442697747.png

 

Hi again 

Can you share a pbix with dummy values?

You need to change your model, you can't have 3 different tables and then ask to make a calculation on the 3 at same time.

 

BR 

Bruno 

 


Best regards


Bruno Costa | Super User


 


Did I help you to answer your question? Accepted my post as a solution! Appreciate your Kudos!! 


Take a look at the blog: PBI Portugal 


 


Anonymous
Not applicable

I appended the tables but then I got a different question:
How Combine rows based on Unique ID? Please click on the link
https://community.powerbi.com/t5/Desktop/Combine-rows-based-on-Unique-ID/m-p/2805715

Hi 

You nedd to have something like this 

 

onurbmiguel__0-1664484898524.png

 

the tips is to use the first day (or the last day) of the month in the date column from fact table so you have a relationship 1 -> *

after you can use the Year and month from the calendar table into the visual 

 

Best regards

Bruno Costa | Responsive Resident

 

Did I help you to answer your question? Accepted my post as a solution! Appreciate your Kudos!! 👍

Take a look at the blog: PBI Portugal 

 

wp-1586527108426

 

 


Best regards


Bruno Costa | Super User


 


Did I help you to answer your question? Accepted my post as a solution! Appreciate your Kudos!! 


Take a look at the blog: PBI Portugal 


 


Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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
Top Kudoed Authors