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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

How to fill the null value with product average in power bi

I have one table with missing value for unit price column. I want fill this in power query with average. I am able to fill the null with entire column average. But I want to consider the product name column while finding the average. I want group by average to fill the null missing unit price column Please help me to get some solution

So far I tried with below code : =

if [unit price] = null then List. Average(#"Added Custom"[unit price]) else [unit price]

 

But here I don't know how to consider the product name while finding the average

 

Product NameUnit Price
Anull
A30.1
A42.9
B48.7
B56.8
B60.3
C22.0
Cnull
C24.3
1 ACCEPTED SOLUTION
HotChilli
Super User
Super User

Duplicate the Query - (let's call it 2ndTable).

In 2ndTable, do a Group By on Product, using average of the Unit price as aggregation.

--

Merge the original table with 2ndTable on ProductName to bring the average back to the original table.

You can then have

Product 'UnitPrice' avg    in the resulting table.

--

Add a custom column to either return UnitPrice or avg if UnitPrice is null

View solution in original post

1 REPLY 1
HotChilli
Super User
Super User

Duplicate the Query - (let's call it 2ndTable).

In 2ndTable, do a Group By on Product, using average of the Unit price as aggregation.

--

Merge the original table with 2ndTable on ProductName to bring the average back to the original table.

You can then have

Product 'UnitPrice' avg    in the resulting table.

--

Add a custom column to either return UnitPrice or avg if UnitPrice is null

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.