Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Individual and Group average

Hello,

 

I have the following puzzle that I am trying to resolve and so far I was not able to find a good solution to it (DAX).

 

The raw data table looks like:

NameActivitiesDate
John22019-07-07
John32019-07-08
John42019-07-12
Deanna32019-07-08
Deanna42019-07-09
Deanna52019-07-11

 

I want to know the Average activities per day per "employee" so I have created two measures:

1- Worked days = DISTINCTCOUNT(Date)

2- Total Activities = SUM(Activities)

3- Avg Activities = Total Activities / Worked Days / DISTINCTCOUNT(Name) 

 

Which yield the expected results:

NameAvg ActivitiesTotal ActivitiesWorked days
John393
Deanna4123

 

So far so good, now I want to calculate the Average activities per day per name of the team, you would say that the above is pretty simple, just remove the Name component and I should get the team average:

 

Avg ActivitiesTotal ActivitiesWorked daysDISTINCTCOUNT(Name) 
2.12152

 

As you can see the average result of 4.2 is not the right one, it should be 3.5 (in this case I've simulated the data to be simple at the eye). 

 

This result is given by the way that Worked days counts the number of "active days" of each employee.

 

I think that a weighted average would work, but I have not been able to identify the right way to do it in PowerBI

3 Replies