SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Measure between dates


Measure between dates

Author
Message
aruna.sriram099
aruna.sriram099
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 21
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??
ShineBoy
ShineBoy
SSC-Enthusiastic
SSC-Enthusiastic (114 reputation)SSC-Enthusiastic (114 reputation)SSC-Enthusiastic (114 reputation)SSC-Enthusiastic (114 reputation)SSC-Enthusiastic (114 reputation)SSC-Enthusiastic (114 reputation)SSC-Enthusiastic (114 reputation)SSC-Enthusiastic (114 reputation)

Group: General Forum Members
Points: 114 Visits: 155
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..
Mackers
Mackers
SSC Veteran
SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)SSC Veteran (225 reputation)

Group: General Forum Members
Points: 225 Visits: 499
There is a very recent thread on this already

http://www.sqlservercentral.com/Forums/Topic1407198-17-1.aspx

Mack
aruna.sriram099
aruna.sriram099
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 21
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..
stevefromOZ
stevefromOZ
Hall of Fame
Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)

Group: Moderators
Points: 3434 Visits: 3757
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.
aruna.sriram099
aruna.sriram099
Forum Newbie
Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)Forum Newbie (3 reputation)

Group: General Forum Members
Points: 3 Visits: 21
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
stevefromOZ
stevefromOZ
Hall of Fame
Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)Hall of Fame (3.4K reputation)

Group: Moderators
Points: 3434 Visits: 3757
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.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search