0
votes

I am attempting to show the avearage duration of the various parts of our hiring process via a pivot table from PowerPivot. So, for example, you will be able to see the average time a candidate is in the "interview" stage as part of the entire process. The fact table I'm working with AppDuration is broken down by candidate, by position, and by duration. Here is a sample of the data:

RequisitionID    CandidateID      Req-CandidateKey   HireStatus     Duration
555              111              555_111            App Review     3
555              111              555_111            Phone Screen   5
555              111              555_111            Interview      7
555              222              555_222            Phone Screen   10
666              333              666_333            App Review     12
666              333              666_333            Phone Screen   15
666              444              666_444            App Review     5
666              444              666_444            Phone Screen   4
666              444              666_444            Offer Extend   15

I also have a lookup table StatusMaster to group the various HireStatus values

HireStatus     StatusCategory
App Review     Initial
Phone Screen   Intermediate
Interview      Intermediate
Offer          Final

AppDuration and StatusMaster are joined via a relationship on HireStatus. I want to examine the average duration at the StatusCategory level.

My thought is that I first need a count of distinct instances of requisition-candidate combination, so I created measure

DistinctReqApplicants:=DISTINCTCOUNT(AppDuration[Req-CandidateKey])

Then sum the Duration field

DurationTotal:=SUM(AppDuration[Duration])

And then just divide the two

CandidateAvgDur:=DIVIDE([DurationTotal], [DistinctReqApplicants])

I then create a pivot table where drop CandidateAvgDuration in the values and the StatusCategory in the rows. But the problem is that the Grand Total does not equal the sum of the category averages

Screen shot of pivot table result In my results the Grand Total should be 38.3 when you sum up the individual categories, but instead is 23.0. I don't have any other filters applied. I am baffled because this seems straight-forward based on examples I've looked up and posts I've referenced on here. However I am a total noob when it comes to PowerPivot so I'm sure my lack of experience is at work here. Any help or suggestion is appreciated.

1
If total duration is 3+5+7+10+12+15+5+4+15 = 76 and you have 4 distinct candidates, then I'd expect your average to be 76/4 = 19. Why do you think it should be 38.3?Alexis Olson
Sorry, the expected totals are based on my entire data set. The data included in the post is just a sample of it. The problem is really the mismatch between the Grand Total and the sum of the category averages.rootdown42
In general, the sum of averages is not the same as taking the overall average nor should it be. This article may be useful: powerpivotpro.com/2012/03/…Alexis Olson
Thank you for your response @AlexisOlson. I have reviewed the article and while I understand the need for row iteration when it comes to averages I can't say I totally understand what drives the need for the IF( COUNTROWS()) as the linked article was not totally clear to a noob such as myself. Also not sure why the answer from GregGalloway (below) works without any IF( COUNTROWS()) functionality.rootdown42
It's because they are using two different calculations for two different scenarios: one calculation for a single row and another for multiple rows. In many cases, the multiple row calculation will resolve to the single row case when it calculates inside the filter context of a single row, but this isn't always the case. If the multi-row calculation does not reduce to the one-row calculation, then you need the IF function.Alexis Olson

1 Answers

0
votes

Please try this:

CandidateAvgDur:=SUMX(
 VALUES(AppDuration[HireStatus]),
 DIVIDE([DurationTotal], [DistinctReqApplicants])
)

Is it possible a requisition-candidate can have more than one row per HireStatus. If not then change the DistinctReqApplicants measure to just a COUNTROWS(AppDuration) to improve performance.