I am using direct query in this execrise.
I have a fact table and within the fact table I have a beginning date and and ending date plus a customer and a plan. My dimension table is by month. What I need is a way to get 1 in each month column for each customer no mater what the beginning and end dates are. Here is an example of what my fact table looks like:
Fact table
[Customer key] [Beginning Date key] [Ending Date key], [PlanKey]
123 20140105 20991231 10
456 20160701 20161231 10
789 20151215 20160630 15
012 20160101 20160730 15
345 20160315 20160930 20
My Dimension table for plan is just a key an ID and a plan name.
I need to be able to create a measure that will have 1 in each month that I search for so if I look for 1.1.2016 - 12.31.2016 it should appear like this.
[Plan] [Cust] [Jan 16] [Feb 16] [Mar 16] [Apr 16] [May 16] [Jun 16] [July 16] [Aug 16] [Sep 16] [Oct 16] [Nov 16] [Dec 16] [Total]
10 123 1 1 1 1 1 1 1 1 1 1 1 1 12
10 456 1 1 1 1 1 1 6
15 789 1 1 1 1 1 1 6
15 012 1 1 1 1 1 1 6
20 345 1 1 1 1 1 1 1 7
3 3 4 4 4 4 3 3 3 2 2 2 37
So if my filter date is less or greater than a year I still want the calculation to work.
Please let me know how I can do this thank you in advance?