Hi
I have requirement in MDX . In short trying to get count of records datewise for date range bucket
Just to give small idea on the model
My fact table act as dimension as well. Its having 4 date columns along with other details . Shipments valid from/To date and Container valid from/To date.
Shipment | ||||
Id | ShipValidFrom | ShipValidTo | ContValidFrom | ContValidTo |
S1 | 10/9/2012 | 10/30/2012 | 10/9/2012 | 10/13/2012 |
S1 | 10/9/2012 | 10/30/2012 | 10/14/2012 | 10/30/2012 |
S2 | 10/20/2012 | 10/25/2012 | 10/20/2012 | 10/30/2012 |
S2 | 10/26/2012 | 10/30/2012 | 10/20/2012 | 10/30/2012 |
And a dimension table where ID is from above is primary in dimension
DimRoute
KeyDim1 Departure Date
S1 10/25/2012
S2 10/25/2012
S3 10/30/2012
Also I have a Date dimension with date as key linked with Departure date of DimRoute
DimDate
Date Week Year
10/25/2012 43 2012
10/26/2012 43 2012
10/27/2012 43 2012
10/28/2012 43 2012
10/29/2012 44 2012
10/30/2012 44 2012
10/31/2012 44 2012
The requirement is that whenever I drag any date/week from Dimdate it shld give set of days and corresponding count of records first valid for Shipment date range and then Containers date range valid for those shipments .
Like I select 10/25/2012 as departure date in filter or column then how count is placed in approp bucket is shown with color code from fact
|
| Shown For understanding only , internal calculation |
| |
Date range | Day range | For S1 | For S2 | Total Count ( which is actual measure) |
10/30/2012 | -5 | 1 | 1 | 2 |
10/29/2012 | -4 | 1 | 1 | 2 |
10/28/2012 | -3 | 1 | 1 | 2 |
10/27/2012 | -2 | 1 | 1 | 2 |
10/26/2012 | -1 | 1 | 1 | 2 |
10/25/2012 | 0 | 1 | 1 | 2 |
10/24/2012 | 1 | 1 | 1 | 2 |
10/23/2012 | 2 | 1 | 1 | 2 |
10/22/2012 | 3 | 1 | 1 | 2 |
10/21/2012 | 4 | 1 | 1 | 2 |
10/20/2012 | 5 | 1 | 1 | 2 |
10/19/2012 | 6 | 1 |
| 1 |
10/18/2012 | 7 | 1 |
| 1 |
10/17/2012 | 8 | 1 |
| 1 |
10/16/2012 | 9 | 1 |
| 1 |
10/15/2012 | 10 | 1 |
| 1 |
10/14/2012 | 11 | 1 |
| 1 |
10/13/2012 | 12 | 1 |
| 1 |
10/12/2012 | 13 | 1 |
| 1 |
10/11/2012 | 14 | 1 |
| 1 |
10/10/2012 | 15 | 1 |
| 1 |
10/9/2012 | 16 | 1 |
| 1 |
So rite now its only two shipments S1 and S2 shown but it will take all shipment for departure date 10/25/2012 . the dayrange span goes from (42….3,2,1,0,-1,-2.. -5)
I tried to achieve this with MDX using sets , cross join and date range but cldnt get as I am not much proficient in writing MDX .
FYI , I have achieved this already in Tabular model by generating records for each valid date in the Fact query itself i.e create records from 10/9/2012 to 10/30/2012 and corresponding day range w.r.t to departure date .
But that is not an efficient way of doing as when full dataset is considered it generates records and crosses rows in billions
I must achieve this dynamically in the Multidimensional model . Any help on how I can achieve this is much appreciated . Suggestion in slight changes in the model/relationship is welcomed
Thanks in advance