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
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
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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

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.