cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper I
Helper I

Calculate the average of values across several columns in same row?

For each observation (row), I am trying to add a calculated column that displays the average across seven columns and I am stuck. I guess what I am looking for is a "row average" that will ignore null values. Here's the structure:

 

Capture.PNG

 

 

 

 

 

 

 

 

For the first observation, PCODE 8411, the average of these seven columns, ignoring null values, is [(1+4+1+1)/4] = 1.75.

 

There are approximately 30 columns, so I only want to average these seven.

 

Any help would be great!

 

Thank you!

10 REPLIES 10
Highlighted

Hi @swragg ,

I believe you need a bit of a different approach here. Add a column like so:

 

List.Average ( List.Select ( Record.FieldValues ( [FirstColumn] & [SecondColumn] & [ThirdColumn] ), (x) => x <> null ) )

 

 

 

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Community Conference

Microsoft Power Platform Communities

Check out the Winners!

secondImage

Create an end-to-end data and analytics solution

Learn how Power BI works with the latest Azure data and analytics innovations at the digital event with Microsoft CEO Satya Nadella.

Top Solution Authors
Top Kudoed Authors