# How to calculate Backlog Status



## nirajkrishna (Mar 12, 2013)

I have a fact table with the following columns:

JobID, Sales $s, Credit Date, Contract Date, Measure Date, Warehouse   Date, Production Date, Installation Date. A job progresses through the   production cycle in the same order as the way I have the columns listed.   We want to be able to view our $'s that are in each cycle on any given   date.

For example 


JobIDSalesCredit DateContract DateMeasure DateWarehouse DateProduction DateInstallation Date15001/1/20131/7/20131/13/20131/19/20131/25/20131/31/201324001/6/20131/12/20131/18/20131/24/20131/30/20132/5/201333001/11/20131/17/20131/23/20131/29/20132/4/20132/10/201342001/16/20131/22/20131/28/20132/3/20132/9/20132/15/201351001/21/20131/27/20132/2/20132/8/20132/14/20132/20/2013

<tbody>

</tbody>
If I were to look at Contract $'s by date then I want to see:


Contract $'s(Contract - Credit)JobID1/1/20131/2/20131/3/20131/4/20131/5/20131/6/20131/7/20131/8/20131/9/20131/10/20131/11/201315005005005005005002400400400400400400330045

<tbody>

</tbody>


And then for Measure $'s I want to see:


Measure $'s(Measure - Contract)JobID1/1/20131/2/20131/3/20131/4/20131/5/20131/6/20131/7/20131/8/20131/9/20131/10/20131/11/201315005005005005002345

<tbody>

</tbody>

I have a date table, but I do not know how to write the dax to make the numbers filter properly. Any help is appreciated.


----------



## Jacob Barnett (Mar 13, 2013)

I've uploaded a potential solution here: https://docs.google.com/file/d/0Bz5yMU2oooW2TGZjMWdYWU1kOHc/edit?usp=sharing

That's the good news, the bad news is that I had to 'flatten' your fact table so that each entry has its own record - this is a far more common way for this kind of data to be used. I don't know how practical this is for you in real life but the likelihood is that the data was originally captured and stored in this format.

In a Nutshell I:

 - Created a separate date table that contains unique, contiguous dates which is related to the fact table.
 - Wrote measures that derive the 2 dates required for the first PIVOT (you will need to complete this task for all date types).
 - Used the 2 date measures to write an excel IF style formula to determine whether that particular date was in the range in question. Crucially I included an ALL() against the date table that opened out the date context from the individual date in question (a CRUCIAL DAX technique).

And that's it. Hope this helps, happy to discuss further.
Jacob


----------



## nirajkrishna (Mar 13, 2013)

Just what I was asking for! Perfect! I had my fact table flattened like you did, but I noticed performance degradation. Is that to be expected? I thought PP was great at handling columnar data. Maybe I had some bad measures. I cant really remember. Thanks for this!


----------



## Jacob Barnett (Mar 13, 2013)

Glad it was useful. PowerPivot is _ALWAYS_ better with flattened tables as the storage is columnar! There are a bunch of things you can try to improve performance but one of the weird ones is that sorting by low cardinality columns on import can significantly help performance in some circumstances.


----------

