January 16, 2013 at 2:20 am
I have a campaign dimension ( Its a marketing campaign for a product ) and i have to measure the sales that happened during the campaign , Each campaign will have a duration ( start date and end date )
For Example : a sample record in the campaign dimension looks like this
CampaignKey : 1
CampaignName: XXXX
Cam[aignStartDate :01-01-2012
CampaignEndDate :11-01-2012
StartKey : 74561 ( refers to the primary key in time dimension )
EndKey :74667 ( refers to the primary key in time dimension )
i need to analyse the total sales that happened during a campaign , the cube should be able to get the sales figure that happened between the start date and the end date for the given campaign ( i also have a time key in the fact table )
To do this i have added campaign key to the fact table and got the result.But in my campaign table there are also columns precampaigndate and postcampaigndate which are campaigndate-duration and campaigndate+duration respectively.
Now i want sales happend between precampaigndate to startdate and sales happend between postcampaigndate and enddate.
Could someone please help me out how to do this??
January 16, 2013 at 2:28 am
Not sure I get all that you are saying, as it seems simple enough just use "where Salesdate between campaignstartdate and Campaignenddate"
Or am I missing something..
January 16, 2013 at 2:32 am
There is a very recent thread on this already
http://www.sqlservercentral.com/Forums/Topic1407198-17-1.aspx
Mack
January 16, 2013 at 2:34 am
when i added the campaign key to the fact table i got the data between start and end date.
But now i want the data between precampaigndate and start date
I tried this expression,
({[Campaign].[PreCampaignDate]:[Campaign].[StartDate]},[Measures].[Sales])
but it is giving null as result..
January 16, 2013 at 9:03 am
Hmmm, extremely similar thread - si there a college problem we're all now trying to solve or folks are using multiple accounts maybe?? :hehe:
Regardless, although on the other thread I had originally recommended adding the Campaign ID to the Fact, you can't do that *UNLESS* you can guarantee that there is (and will ever be) only 1 campaign running on any given date. If you can guaranttee that, then sure, it can be part of the Fact. If you can't, then you're going to want to look at Many to many.
This thread also changes the problem/solution slightly (IMO) - to answer this specific question, you would likely just use straight MDX (ie use a specific report/query) where as on the other thread, one would use the cube design, though one could easily use MDX for that problem too.
Steve.
January 17, 2013 at 3:24 am
thank You Steve,
But what would be the mdx query?
I tried,
SELECT NON EMPTY { [Measures].[Sales] } ON COLUMNS, NON EMPTY { ([Dim Employee].[Franchise Name].[Franchise Name].ALLMEMBERS ) } DIMENSION PROPERTIES MEMBER_CAPTION, MEMBER_UNIQUE_NAME ON ROWS FROM ( SELECT ( { [Campaign].[Campaign ID].&[1] } ) ON COLUMNS FROM [Food Processing DWH]) WHERE ( [Campaign].[Campaign ID].&[1] )
But it is giving values at the enddate..i want the range of values between start and end date
January 17, 2013 at 10:37 am
If you want to use the Campaign as the filter element, then as I see it, you'd want to implement many-to-many. The reason being, your campaign has two (2) dates, but based on what I've seen/heard, your joining (in the model) only on one (sounds like end date).
Otherwise, the MDX would need to simply be filtered using the (assumed known) start and end dates for a given campaign - i.e. *you* need to know those dates and manually specify them. This will obviously *not* work for a non tech end user situation. Again, IMO, if you want it to work for end usrs, get a many to many relationship going (using a bridging table) between Campaign -> Bridge <- Date.
A possible alternative to above, is to try to use the properties of the selected Campaign (eg have start and End date as attributes) and then striing them into the SELECT statement, sort of like "SELECT ........ FROM ..... WHERE[Date].[Date].' + CSTR(GetMePropertyromAttibutehere) + ':' + CStr(GetmeEndDatePropertyValuehere()) I haven't one this, but imagine it's possible.
Steve.
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply