Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


get weekday in mdx


get weekday in mdx

Author
Message
mvee
mvee
SSC Eights!
SSC Eights! (967 reputation)SSC Eights! (967 reputation)SSC Eights! (967 reputation)SSC Eights! (967 reputation)SSC Eights! (967 reputation)SSC Eights! (967 reputation)SSC Eights! (967 reputation)SSC Eights! (967 reputation)

Group: General Forum Members
Points: 967 Visits: 449
I have a dimension that has a date field in it. i would like to create a metric for weekend = yes or no.
But I cannot, for the life of me, figure out how to get the date or a datepart from the value.
I'll try to give enough details below.

The CI field looks like this: 2009-01-04 00:00:00.000

When I try something like this:
Set [CI weekday] as (VBA!Weekday([Comparison Group].[CI].[CI]))

I get:
Execution of the managed stored procedure Weekday failed with the following error: Microsoft::AnalysisServices::AdomdServer::AdomdException.
Query (44, 21) The function expects a string or numeric expression for the 1 argument. A level expression was used.

When I try something like this:
MEMBER [Comparison Group].[CI].[CI weekday] as (VBA!Weekday([Comparison Group].[CI].[CI].currentmember))

I get the CI weekday as a column value and an error for the metric.

Obviously, I'm a newbie. Any direction, things to try, hints on how to describe better, etc would be greatly appreciated.

Thanks, Megan



stevefromOZ
stevefromOZ
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: Moderators
Points: 1929 Visits: 3754
One approach is to add it before you get to the dimension. So, in the Data Source View, right click the table name and select the option to add a new Named Calculation. Assuming a SQL data source, the calc text will be valid TSQL (so, in this case likely the use of Datepart and a case statement - ie use the TSQL you'd use to create a true/false value in a column in a sql query).

Once you have your new named calc, go to edit the dimension, and add this field as a new Attribute Dimension within the dim - the name could be something like 'Is Weekend' and the values would be 'Yes' and 'No'.

HTH,

Steve.
mvee
mvee
SSC Eights!
SSC Eights! (967 reputation)SSC Eights! (967 reputation)SSC Eights! (967 reputation)SSC Eights! (967 reputation)SSC Eights! (967 reputation)SSC Eights! (967 reputation)SSC Eights! (967 reputation)SSC Eights! (967 reputation)

Group: General Forum Members
Points: 967 Visits: 449
Thanks Steve. Do you know if you have to reprocess the entire cube to see this new value? Thanks again. -Megan



stevefromOZ
stevefromOZ
SSCommitted
SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)SSCommitted (1.9K reputation)

Group: Moderators
Points: 1929 Visits: 3754
You *should* be able to do a process update on the dimension alone, but not being there and seeing what you've got, I could be wrong and it may require a full reprocess Sad One thing you may want to try is the Impact Analysis (*prior* to clicking OK/RUn :-) ) to see if it can tell what other objects (such the cube/partitons) will be affected.

Steve.
mvee
mvee
SSC Eights!
SSC Eights! (967 reputation)SSC Eights! (967 reputation)SSC Eights! (967 reputation)SSC Eights! (967 reputation)SSC Eights! (967 reputation)SSC Eights! (967 reputation)SSC Eights! (967 reputation)SSC Eights! (967 reputation)

Group: General Forum Members
Points: 967 Visits: 449
cool. thanks!



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