Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Measure between dates Expand / Collapse
Author
Message
Posted Wednesday, January 16, 2013 2:20 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, January 24, 2013 10:42 PM
Points: 3, Visits: 18
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??
Post #1407691
Posted Wednesday, January 16, 2013 2:28 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, November 11, 2014 2:21 PM
Points: 24, Visits: 83
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..
Post #1407695
Posted Wednesday, January 16, 2013 2:32 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Monday, January 13, 2014 7:34 AM
Points: 117, Visits: 499
There is a very recent thread on this already

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

Mack

Post #1407698
Posted Wednesday, January 16, 2013 2:33 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, January 24, 2013 10:42 PM
Points: 3, Visits: 18
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..
Post #1407700
Posted Wednesday, January 16, 2013 9:03 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: Moderators
Last Login: Yesterday @ 7:18 AM
Points: 1,836, Visits: 3,544
Hmmm, extremely similar thread - si there a college problem we're all now trying to solve or folks are using multiple accounts maybe??

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.
Post #1407905
Posted Thursday, January 17, 2013 3:24 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, January 24, 2013 10:42 PM
Points: 3, Visits: 18
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
Post #1408277
Posted Thursday, January 17, 2013 10:37 AM


SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: Moderators
Last Login: Yesterday @ 7:18 AM
Points: 1,836, Visits: 3,544
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.
Post #1408544
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse