Forum Discussion
Anonymous
6 years agoNot applicable
Calculate average by group ignoring certain filter
Hello, my data looks like the following Date Emloyee Group Task Duration 2020-01-01 A 1 aa 2 2020-01-01 ...
v-alq-msft
Community Support
6 years agoHi, Anonymous
Based on my research, you may create two measures as below.
EmpAvg =
var _emp = SELECTEDVALUE('Table'[Employee])
var _task = SELECTEDVALUE('Table'[Task])
return
CALCULATE(
AVERAGE('Table'[Duration]),
ALLEXCEPT('Table','Table'[Employee],'Table'[Task],'Table'[Date])
)
GroupAvg =
var _emp = SELECTEDVALUE('Table'[Employee])
var _task = SELECTEDVALUE('Table'[Task])
return
CALCULATE(
AVERAGE('Table'[Duration]),
FILTER(
ALLEXCEPT('Table','Table'[Task],'Table'[Date]),
'Table'[Group] in
CALCULATETABLE(
DISTINCT('Table'[Group]),
FILTER(
ALL('Table'),
'Table'[Employee] =_emp
)
)
)
)
Result:
Best Regards
Allan
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Anonymous6 years agoNot applicable
Hi v-alq-msft
thanks for your answer!
I tried it, however, I forgot to mention that my data is in three different tables - one fact table with the tasks and their durations and two dimension tables (one for employees and one for dates). Due to this your mesaure GroupAvg doesn't work. How can I use your measure with multiple tables? Thanks!