Hello,
I am trying to provide a pivot table showing hourly availability of staff. My data model contains a date table and an hours table.
Example of what i want to acheive:
[TABLE="width: 500"]
<tbody>[TR]
[TD]Date[/TD]
[TD]Hour[/TD]
[TD]Staff[/TD]
[/TR]
[TR]
[TD]1/1/2013[/TD]
[TD]7[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]1/1/2013[/TD]
[TD]8[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]1/1/2013[/TD]
[TD]9[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]1/1/2013[/TD]
[TD]10[/TD]
[TD]5[/TD]
[/TR]
</tbody>[/TABLE]
Staff is just the number of people on shift multiplied by the number that are available for that hour.
My fact table looks like the following (this is linked to my dates table):
[TABLE="width: 500"]
<tbody>[TR]
[TD]Date[/TD]
[TD]7 Shift[/TD]
[TD]8 Shift[/TD]
[TD]9 Shift[/TD]
[/TR]
[TR]
[TD]1/1/2013[/TD]
[TD]1[/TD]
[TD]3[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]2/1/2013[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]3/1/2013[/TD]
[TD]1[/TD]
[TD]3[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]4/1/2013[/TD]
[TD]2[/TD]
[TD]4[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]5/1/2013[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]6/1/2013[/TD]
[TD]2[/TD]
[TD]4[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]7/1/2013[/TD]
[TD]1[/TD]
[TD]4[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]8/1/2013[/TD]
[TD]1[/TD]
[TD]4[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]9/1/2013[/TD]
[TD]1[/TD]
[TD]3[/TD]
[TD]1[/TD]
[/TR]
</tbody>[/TABLE]
Now, I have created a reference table to show what shifts work what hours (including assigned lunch times), this is linked to my hours table. Looking like this (but with all 24hours of the day in it):
[TABLE="width: 500"]
<tbody>[TR]
[TD]Hour[/TD]
[TD]7 Shift[/TD]
[TD]8 Shift[/TD]
[TD]9 Shift[/TD]
[/TR]
[TR]
[TD]7:00:00AM[/TD]
[TD]1[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]8:00:00AM[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]9:00:00AM[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]12:00:00PM[/TD]
[TD]0[/TD]
[TD]1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]1:00:00PM[/TD]
[TD]1[/TD]
[TD]0[/TD]
[TD]1[/TD]
[/TR]
</tbody>[/TABLE]
Now for the life of me I cant seem to be able to write a measure to pull these together. As the hour and date tables dont have a relationship and the shift table and fact table dont have a relationship.
I have tried to write a crossjoin but cant find any information on referencing which column that I want to use in the calculation formula. I feel that this should be an easy problem to solve but at the moment it is doing my head in. Does anyone have any suggestions on what would be the best approach for this?
I am trying to provide a pivot table showing hourly availability of staff. My data model contains a date table and an hours table.
Example of what i want to acheive:
[TABLE="width: 500"]
<tbody>[TR]
[TD]Date[/TD]
[TD]Hour[/TD]
[TD]Staff[/TD]
[/TR]
[TR]
[TD]1/1/2013[/TD]
[TD]7[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]1/1/2013[/TD]
[TD]8[/TD]
[TD]4[/TD]
[/TR]
[TR]
[TD]1/1/2013[/TD]
[TD]9[/TD]
[TD]5[/TD]
[/TR]
[TR]
[TD]1/1/2013[/TD]
[TD]10[/TD]
[TD]5[/TD]
[/TR]
</tbody>[/TABLE]
Staff is just the number of people on shift multiplied by the number that are available for that hour.
My fact table looks like the following (this is linked to my dates table):
[TABLE="width: 500"]
<tbody>[TR]
[TD]Date[/TD]
[TD]7 Shift[/TD]
[TD]8 Shift[/TD]
[TD]9 Shift[/TD]
[/TR]
[TR]
[TD]1/1/2013[/TD]
[TD]1[/TD]
[TD]3[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]2/1/2013[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]3/1/2013[/TD]
[TD]1[/TD]
[TD]3[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]4/1/2013[/TD]
[TD]2[/TD]
[TD]4[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]5/1/2013[/TD]
[TD]2[/TD]
[TD]3[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]6/1/2013[/TD]
[TD]2[/TD]
[TD]4[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]7/1/2013[/TD]
[TD]1[/TD]
[TD]4[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]8/1/2013[/TD]
[TD]1[/TD]
[TD]4[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]9/1/2013[/TD]
[TD]1[/TD]
[TD]3[/TD]
[TD]1[/TD]
[/TR]
</tbody>[/TABLE]
Now, I have created a reference table to show what shifts work what hours (including assigned lunch times), this is linked to my hours table. Looking like this (but with all 24hours of the day in it):
[TABLE="width: 500"]
<tbody>[TR]
[TD]Hour[/TD]
[TD]7 Shift[/TD]
[TD]8 Shift[/TD]
[TD]9 Shift[/TD]
[/TR]
[TR]
[TD]7:00:00AM[/TD]
[TD]1[/TD]
[TD]0[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]8:00:00AM[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]0[/TD]
[/TR]
[TR]
[TD]9:00:00AM[/TD]
[TD]1[/TD]
[TD]1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]12:00:00PM[/TD]
[TD]0[/TD]
[TD]1[/TD]
[TD]1[/TD]
[/TR]
[TR]
[TD]1:00:00PM[/TD]
[TD]1[/TD]
[TD]0[/TD]
[TD]1[/TD]
[/TR]
</tbody>[/TABLE]
Now for the life of me I cant seem to be able to write a measure to pull these together. As the hour and date tables dont have a relationship and the shift table and fact table dont have a relationship.
I have tried to write a crossjoin but cant find any information on referencing which column that I want to use in the calculation formula. I feel that this should be an easy problem to solve but at the moment it is doing my head in. Does anyone have any suggestions on what would be the best approach for this?