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

Replace null values with conditional average

Help please!

I'm still fairly new to Power BI and am trying to replace null values in my data with the average of the previous 3 months with some conditions. 

I have simplified the 2 tables to demonstrate my scenario: 

- Units Sold table: shows the number of units sold by a particular employee in a particular month

- Employee Details table: shows if the employee is still employed with the company or has left (and the date their employment ended)

 

In my Units Sold table, i want to replace all the null values with the average from the previous 3 months data for that particular person, even if one month in the previous 3 is also a calculated average (see desired value for Jessica in 1/05/2021). Before calculating this average, i would need to be able to check the Employee Details table to ensure the person is still employed - any null values after the Emp. End date should remain null. 

 

EmployeeDateUnits SoldExpected Value
Jessica1/01/20212875 
Jessica1/02/20213452 
Jessica1/03/20211217 
Jessica1/04/2021null2515
Jessica1/05/2021null2395
Jessica1/06/20215816 
Jessica1/07/20211056 
Jessica1/08/2021null3089
Jessica1/09/20214956 
Jessica1/10/20212534 
Jessica1/11/20217512 
Jessica1/12/20213185 
Abigail1/01/20215672 
Abigail1/02/20218495 
Abigail1/03/20212356 
Abigail1/04/2021null5508
Abigail1/05/20214675 
Abigail1/06/20211523 
Abigail1/07/2021nullnull
Abigail1/08/2021nullnull
Abigail1/09/2021nullnull
Abigail1/10/2021nullnull
Abigail1/11/2021nullnull
Abigail1/12/2021nullnull

 

EmployeeEmployment StatusEmp. End date
JessicaEmployed 
AbigailResigned29/06/2021

 

Any help on the best way to tackle this in power query would be greatly appreciated!

0 REPLIES 0

Helpful resources

Announcements
Power Apps News & Annoucements carousel

Power Apps News & Announcements

Keep up to date with current events and community announcements in the Power Apps community.

Community Call Conversations

Introducing the Community Calls Conversations

A great place where you can stay up to date with community calls and interact with the speakers.

Power Apps Community Blog Carousel

Power Apps Community Blog

Check out the latest Community Blog from the community!

Top Solution Authors
Top Kudoed Authors
Users online (2,653)