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

A new Data Days event is coming soon! This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. Don't miss out.

Reply
johankent30
Helper I
Helper I

Power Query Column Average

I am trying to calculate the average of a column in power query. The column does have some null values but I've tried replacing them and I still can't get List.Average() to work.. I am getting the error message that it can't convert the value to a list. Any thoughts on how to do this in M? Picture is attached belowerr.JPG

1 ACCEPTED SOLUTION
OwenAuger
Super User
Super User

Hi @johankent30 

I take it you want the same average value in every row of the new colum.

 

The code for the Added Custom step should be

= Table.AddColumn(#"Changed Type", "Custom", each List.Average(#"Changed Type"[CashFlow_Cust.Due_Days]))

Is that what you are seeing in the formula bar?

 

It's working in a test query I created similar to yours, with a mixture of numbers and nulls.

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

View solution in original post

2 REPLIES 2
OwenAuger
Super User
Super User

Hi @johankent30 

I take it you want the same average value in every row of the new colum.

 

The code for the Added Custom step should be

= Table.AddColumn(#"Changed Type", "Custom", each List.Average(#"Changed Type"[CashFlow_Cust.Due_Days]))

Is that what you are seeing in the formula bar?

 

It's working in a test query I created similar to yours, with a mixture of numbers and nulls.

 

Regards,

Owen


Owen Auger
Did I answer your question? Mark my post as a solution!
Blog
LinkedIn

Hi,

I am a newbie to PowerQuery, the above solution is very good. However, I have a little more complex query on this.

Suppose I have Country column, Value column. Now I wanted to average the Value column not equal to 0, for each country in the country column.  Kindly see the below example.

anvikuttu_0-1600515234584.png

 

Let me know if you have any questions.

 

Thank you...

Vj

Helpful resources

Announcements
Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.