“I Want to Taste You But Your Lips are Venomous, PWAH-SAAHHHNNN!!!!”(Get It? Poisson/Poison? OK, Read on for a Bell Biv Devoe Reference)

Intro from Rob

Um, wow. A few things:

Brace yourselves for a dose of awesome.

I don’t understand everything that’s happening in this guest post.

So if you “get” all of this, fantastic.

If you don’t, don’t sweat it – just bask in the power of our toolet – it can truly do anything.

Our new friend Josh is absolutely killing it with his song references.

Take it Away, Josh…

Since taking on a role in Work Force Management about a year ago, I’ve learned one thing: Staffing a call center is expensive. What I mean is: the staffing software, it’s is rather pricey. So much so, that smaller call centers just can’t afford the tools needed to easily create an accurate staffing model.

But as someone raised to the mantra of: “if you are going to do something, do it right” I decided to learn me some DAX. (To be fair though, what my dad really said was: “Aim low, that way no one can tell when you fail.” But for the sake of this post, we’ll go with the first quote. )

Luckily, Rob was nice enough to teach us the core of using complex equations in his Experiments in Linear Regressing, Parts 1 & 2. So we won’t be entirely lost in new territory, it’ll be more of a: “lost with friends and colleagues, ‘Danger Will Robinson’” sort of excursion.

Using RankX and SumX to create a weighted moving average

The staffing model I use relies on a weighted average of the 4 most recent weeks of incoming calls. Often times however, a week’s data may have been inaccurate, causing us to go a week further back.

The way a weighted average works is that each number is multiplied by the given weight and then divided by the the sum of all weights. So the weights 40, 30, 20, and 10 are assigned to the weeks, giving us an average number of calls that is more heavily influenced by the most recent week.

The wrong way to do this:

I include it here because the interactions between the eight weight measures are really, really neat to watch.

When I originally learned Power Pivot I had limited myself to the most recent 8 weeks of data and created a whole mess of measures that would change depending on which weeks were “good”.

I started with a sum of each week’s calls. And then created 8 weight measures that change depending on the previous weights and the sums of calls:

Basically if there were no calls for the week, the weight is 0. But if there were, it sums the earlier weights to determine if it needs to carry a weight and what that weight should be.

It was truly neat (Except that it only applied to the most recent 8 weeks and at 8 iterations of sums and weights it would cap my 8 gigs (or roughly 8 billion bytes) of RAM, lock my machine for 10 minutes, run out of memory and cancel the refresh.)

The ol’ Rank() and Switch()

So I said to my friend Meredith: “Friend Meredith, if I’m gonna do it this with a sumX, I need some way to rank the weeks.” To which he replied: “You mean like the Rank function?”

And all we need for a good rank is date key to add to the rows in our callData table. A concatenated [weekYear] will do the trick.

But wait, there’s a problem. If we do a RankX() of the [weekYear] on the CallData table, we end up “skipping” the data that does not exist!

And here is why:

If we don’t have any calls we don’t have a row to evaluate, simple as that. (well, by “we” I mean most people. I do occasionally have a row that says “0 calls” for reasons that I cannot disclose… or understand. )

Q: So how do we fix this?

A: By evaluating the source of the [weekYear] of course, The Date/Time Dimensions table!

With a simple Sum() of the calls we can SumX() the Date / Time Table, rank everything (existent or not), and multiply it by the appropriate weight. Perfect!

Ta-da! Moving weighted average!

No matter what four weeks you have selected in your pivot table you will be given an accurate average weighted to the most recent data.

Drawbacks:

This only works if:

You did it correctly

You are working with a minimum of 4 weeks of data.

Why? Because a weighted product is divided by the sum of the weights and we have ours hard coded into the average (100). I know there is a way to fix this but that’s a bridge for another day. So for now: 4 weeks or no weeks.

You can’t use this for anything other than a total

If you try to look at this on a week by week basis, the coordinates of each calculated field will only have one week to rank, thus each week will always be ranked as 1.

Now for the spicy stuff

Erlang C in PowerPivot

Erlang C is a formula used to determine the likelihood that a phone call will have to hold while everyone is out to lunch. To do it in excel you need the built in Poisson() function and if you want the really good numbers you’ll need some amount of VBA as well. But we work in PowerPivot, that’s why we’re here, and DAX does not have a Poisson function. <–(sad face).

The Erlang C Formula:

It looks big and scary BUT, it only has the two variables: A and N, not so scary anymore. But even easier than that is The Erlang C Formula simplified for Excel:

So really, all we really need is a Poisson measure and we should be good to go.

Let’s take a look at Poisson:

Lucky for us, the Sinclair station down the street from me opened up a delicious Greek restaurant last year. So upon seeing this I was easily able to translate it to English.

Simply put, Poisson takes the average (λ) and tells you the likelihood of your desired outcome (k). It’s called Poisson distribution and math people all over the world use it for stuff. Right along with Cumulative Poisson:

Err… we’ll get back to that one.

Anyway, Poisson!

As Bell, Biv, and DeVoe were so fond of telling us: “She’s the only one that can show us the likelihood of random occurrence because, That girl is Poisson.”

Poisson is comprised of two things, Traffic Intensity and Number of agents.

Traffic Intensity

Calls Expected [or: Average of Calls Offered]

+ Time Interval in Seconds

* Call Duration in Seconds

We already have our average so let’s look at our time interval.

Time Interval in Seconds=

It basically counts the number of rows per time period. My Date/Time table is comprised of 4 rows per hour so we can only have 3 possible outcomes: 15 mins would be every row, 30 would be every two rows, and 1 hour would be every 4. Now, we could staff to a 24 hour period but that’s crazy talk.

Number of Agents

We’ll achieve this with another Disconnected slicer, table, MAX() combo but this time we must make sure to start the Agent table at 0 and go up in increments of 1.

“0” You say? Yes, file it under “i” for: Important.

Poisson

On a side note: For the week or so I spent working on this, I survived two nearly fatal attempts on my life for my incessant singing of the lyrics “…your lips, are, venomous, Poisson”. Just be warned, some people don’t like math.

And now were ready to get this show on the road let’s write a Poisson measure!

Earlier I mentioned that this is what we are aiming for:

And we’ve got all that except the ‘e’ and the ‘!’.

Well, the ‘!’ is the factorial of Number of Agents or: Number of Agents multiplied by every number below it in descending order.

And the ‘e’ is 2.718281828459045. Which is really easy to remember. It’s 2.7 1828 1828 45 90 45

Unfortunately for me I spent time irrationally memorizing that number when DAX has a function for it all along, It’s called EXP(). Why? Because Euler. Oh yeah, there’s a function for factorials: FACT().

Now we can slap that straight into our measure makin’ device and be off to the races.

Cumulative Poisson

Well, now it’s time for this bugger.

All this means that we need to calculate Poisson for every number that is less than the number of agents on staff (including that ever important 0) and then sum the totals. That’s it, pretty simple except that we can’t do it off of the current Agents table because it has to be filtered by the disconnected slicer in order to return the Number of Agents.

So let’s make a duplicate table and name it something silly.

We’ll need to filter this new table to be < numberOfAgents. So if our numberOfAgents = 10 we will run a SUMX() on a filtered version of our table: rows 0 through 9.

Every one of those numbers is important for knowing how poorly your employees will do when the calls start arriving.

We are now the best.

Unless…

Solving for x in Erlang C

As helpful as it is to know what percentage of calls will be answered within our target answer time, the real reason we are here is to find out how many agents we need to answer those calls.

But in that lies our problem. If you remember, Erlang C required Number of Agents to get tell us our Service Level, but let’s say we already know what we would like our Service Level to be. What we now need to know is what number of Agents (x) we will need to reach our Service Level

Well, I don’t math very well but PowerPivot does. So after a little bit (read as: about a week’s worth) of thought I decided to see if I could:

Filter a table, by an equation, that included a column from the same table.

But how do we do that?

Well, we’ll need to replace any, and every instance of our Agents measure with an Agents column reference, that shouldn’t be too hard. Let’s even use a set Desired Service Level of 75 and create a [desiredServiceLevel] once we know it works.

The easiest way to achieve this is to start from the top and replace each measure with the updated code. i.e. where ErlangC requires the [agentOccupancy] measure, replace it with : [trafficIntensity] / XAgentsOnStaff[Agents on Staff]

Now, to save time and space (you can just call me the Dr.) I’ll skip to the finished product.

Our SUMX() will now return a count of the rows that are >= the number Agents needed, an easy number to work with. Just subtract that from our total number of rows + 1, wrap it in an IF() and we’re good to go.

Note: because of the way service level is calculated you can never have a number that is > 100. It’s an impossible equation and PowerPivot will really mess up the numbers trying compute it. Hence the IF() that switches the slicer to 99.

Maybe add a few more slicers to make us feel a little more empowered and…

Done.I’m going to bed.

You can pick up the work book here for more in-depth explanations and examples.

Thanks for sharing that. (I, too, am now in need of some Tylenol.)
Awesome work though!

Now we know why the Poisson (and all the other functions) exists in Excel. I’d go crazy if I had to remember how to rebuild this formula on any type of regular basis. I work with various computer simulation languages, and am reminded (again) of how much I appreciate the built-in functions and statistics.