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
gsamaral77
Helper I
Helper I

Replace null values with average using Power Query

Hey guys, I'm studying Power Query but I'm stuck

 

I have a column "Age" with some null values, I want to replace those with the average. 

 

gsamaral77_0-1652526449539.png

 

That's what I try to do:

 

gsamaral77_1-1652526484341.png

I don't no what I'm doing wrong, someone can help me please?

 

1 ACCEPTED SOLUTION
Vijay_A_Verma
Super User
Super User

Insert this statement

= Table.ReplaceValue(#"Tipo Alterado",each [Age],each if [Age] = null then List.Average(#"Changed Type"[Age]) else [Age],Replacer.ReplaceValue,{"Age"})

View solution in original post

2 REPLIES 2
Vijay_A_Verma
Super User
Super User

Insert this statement

= Table.ReplaceValue(#"Tipo Alterado",each [Age],each if [Age] = null then List.Average(#"Changed Type"[Age]) else [Age],Replacer.ReplaceValue,{"Age"})

That's a good solution! I would actually calculate the List.Average first, make us a variable, so it'll calculate only once. So

avg = List.Average(#"Changed Type"[Column])

 

The in the formula, just replace the text above with avg

 

--Nate

 


I’m usually answering from my phone, which means the results are visualized only in my mind. You’ll need to use my answer to know that it works—but it will work!!

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!

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.

Top Kudoed Authors