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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

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"})
Anonymous
Not applicable

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

 

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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors