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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
DaxNewbie
Frequent Visitor

Dynamic filtering basing on slicer selection

Hello, 

 

I have a dataset including names, titles, tasks, and time worked (see below). I would like to calculate the avg. time worked by task per employee, but also the average time worked by task by the group (indicated by the title) to which that employee belongs. So if an employee is select and she is a partner, the the group average per task would be for only the partners. 

 

Data:

Data.JPG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Avg Per Employee:

 

Avg. per emp.JPG

 

 

 

 

 

 

Avg Per Title: 

 

I understand why 'AvgTime' matches 'AvgTimebyTitle'. I just do not know how to instruct Power BI to find the average for all employees whose title is also 'Partner' (the same title as Amy). 

 

Avg. per title.JPG

 

 

 

 

 

 

 

Currently I am using this code: 

AvgTimebyTitle = CALCULATE(AVERAGE(Sheet1[Time]),Filter(Sheet1, Sheet1[Title] = SELECTEDVALUE(Sheet1[Title])))

 

 

Any assistance is most appreciated. 

 

Cheers!

1 ACCEPTED SOLUTION
Greg_Deckler
Community Champion
Community Champion

I believe you will need to create a VAR that leverages CALCULATETABLE with an ALL('Data'[Title]). Once you have that, then you can do a GROUPBY with an AVERAGEX across that table to get the average you desire. Something like that. Can you post your data in a form that can be easily copied and pasted?

 

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Community Champion
Community Champion

I believe you will need to create a VAR that leverages CALCULATETABLE with an ALL('Data'[Title]). Once you have that, then you can do a GROUPBY with an AVERAGEX across that table to get the average you desire. Something like that. Can you post your data in a form that can be easily copied and pasted?

 

Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler: Thank you so much for replying. I believe that I understand the methodology you explained in your post. 

I am also included the data below in a more copy-friendly format. 

 

Thank you!

 

NameTitleTaskTime
SamManagerResearch2
SamManagerPitch3
SamManagerDeal Closing4
SamManagerAdmin8
SamManagerResearch9
SamManagerPitch2
SamManagerDeal Closing1
SamManagerAdmin6
AmyPartnerResearch7
AmyPartnerPitch8
AmyPartnerDeal Closing8
AmyPartnerAdmin8
AmyPartnerResearch7
AmyPartnerPitch7
AmyPartnerDeal Closing6
AmyPartnerAdmin6
MichellePartnerResearch14
MichellePartnerPitch15
MichellePartnerDeal Closing13
MichellePartnerAdmin12
MichellePartnerResearch10
MichellePartnerPitch11
MichellePartnerDeal Closing12
MichellePartnerAdmin13

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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