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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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
Super User
Super User

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


@ 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!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

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


@ 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!:
The Definitive Guide to Power Query (M)

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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