David -- Notice that Deepak's example has no LODs in it.
I did a different approach that also used table calcs, but the principles are the same so I'll just leave Deepak's solution here.
You need a table calc because you need a running value of some sort to get the average headcount. (I did RUNNING_AVG in mine. Deepak uses a WINDOW_AVG that uses a RUNNING_SUM in his. There are multiple ways to do these things.)
Notice too that Deepak broke apart [Counts] into separate measures. I did the same. It helps with the display of values. Using [Metric(group)] on the sheet creates a structure that is awkward for displaying the final number you need to see.
Greatly appreciate the calc field(s) you helped me with. Is there any way to apply the department filter and flip between departments, it didn't seem to work when I tried it.
I missed the LODs in Deepak's example that are used to break out Headcount and other measures. That's why you need CONTEXT.
You can also break them out just like this (example, for HEadcount):
if [Metric (group)] = "Headcount" then [Counts] END