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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
topcat777
Frequent Visitor

Get Average based on several categories

Hi

 

Hoping you guys can help me. Searched the internet for a soloution but at a loss.

 

I have some data like the below that lets me know the time work has taken. I know anything over 10 in the time column is an error and I want to replace this with the average. So on row 4 I would want to return the average of all Emma's UK Build jobs, excluding the outliers. So in the case, the average or the first 3 rows, as they meet the criteria (Name= Emma, Area = UK, Task = Build, Time <10).

 

Row 8 would also be replaced with 1.5, an average of rows 6 and 7 that meet Emma/UK/Repair/<10. 

 

Job NumberNameAreaTaskTime
1EmmaUKBuild2
2EmmaUKBuild3
3EmmaUKBuild4
4EmmaUKBuild18
5EmmaUSABuild1

6

EmmaUKRepair2
7EmmaUKRepair1
8EmmaUKRepair11
9DaveUKRepair5
10DaveUSARepair1

 

I don't know if this is the best way to do it but I was going to add a column that returned the Time if it was less than 10 but replaced it with the average if it was >=10. For the life of me I just can't figure out how to return that average when I have 3 catagories to match to.

 

I hope you guys can help me.

 

Thanks in advance.

Thom

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

Create a new column like. Link :https://www.dropbox.com/s/2uioqvtxghzr0uo/AverageBaedonCategory.pbix?dl=0

 

Avg Time = 
var _newavg =AVERAGEX(filter(Sheet1,Sheet1[Name]=EARLIER(Sheet1[Name]) && Sheet1[Area]=EARLIER(Sheet1[Area]) && Sheet1[Task]=EARLIER(Sheet1[Task]) && Sheet1[Time]<10),Sheet1[Time])
return
if(Sheet1[Time]<10,Sheet1[Time],_newavg)

 

 

Screenshot 2020-02-05 23.24.26.png

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges

Connect on Linkedin

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

Create a new column like. Link :https://www.dropbox.com/s/2uioqvtxghzr0uo/AverageBaedonCategory.pbix?dl=0

 

Avg Time = 
var _newavg =AVERAGEX(filter(Sheet1,Sheet1[Name]=EARLIER(Sheet1[Name]) && Sheet1[Area]=EARLIER(Sheet1[Area]) && Sheet1[Task]=EARLIER(Sheet1[Task]) && Sheet1[Time]<10),Sheet1[Time])
return
if(Sheet1[Time]<10,Sheet1[Time],_newavg)

 

 

Screenshot 2020-02-05 23.24.26.png

Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution. In case it does not help, please provide additional information and mark me with @
Thanks. My Recent Blog -
Winner-Topper-on-Map-How-to-Color-States-on-a-Map-with-Winners , HR-Analytics-Active-Employee-Hire-and-Termination-trend
Power-BI-Working-with-Non-Standard-Time-Periods And Comparing-Data-Across-Date-Ranges

Connect on Linkedin

Thanks @amitchandak . That worked an absolute treat!

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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