cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Syndicate_Admin
Administrator
Administrator

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?

 

2 REPLIES 2
Syndicate_Admin
Administrator
Administrator

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

 

Helpful resources

Announcements
PA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

This training provides practical hands-on experience in creating Power Apps solutions in a full-day of instructor-led App creation workshop.

Microsoft Build 768x460.png

Microsoft Build is May 24-26. Have you registered yet?

Come together to explore latest innovations in code and application development—and gain insights from experts from around the world.

May UG Leader Call Carousel 768x460.png

What difference can a User Group make for you?

At the monthly call, connect with other leaders and find out how community makes your experience even better.

Top Solution Authors
Users online (1,535)