Solved

MDX Order By

Posted on 2013-01-23
7
582 Views
Last Modified: 2013-01-28
In the following MDX i need to order by [Measures].[ParameterCaption].....
It IS ordering now but it is doing it by alphabetically ..... i need it to treat [Measures].[ParameterCaption] as a date and order it that way


WITH MEMBER [Measures].[ParameterCaption] AS [Accounting Period].[Accounting Period Name].CURRENTMEMBER.MEMBER_CAPTION
     MEMBER [Measures].[ParameterValue] AS [Accounting Period].[Accounting Period Name].CURRENTMEMBER.UNIQUENAME
     MEMBER [Measures].[ParameterLevel] AS [Accounting Period].[Accounting Period Name].CURRENTMEMBER.LEVEL.ORDINAL

SELECT {[Measures].[ParameterCaption], [Measures].[ParameterValue], [Measures].[ParameterLevel] } ON COLUMNS,
       ORDER( {[Accounting Period].[Accounting Period Name].ALLMEMBERS},[Measures].[ParameterCaption], desc) ON ROWS

FROM [MasterCube]
0
Comment
Question by:vbnetcoder
  • 4
  • 3
7 Comments
 
LVL 28

Expert Comment

by:Ryan McCauley
ID: 38813086
Can you just wrap the ORDER BY column in a CDATE?

CDATE([Measures].[ParameterCaption])

Open in new window

0
 

Author Comment

by:vbnetcoder
ID: 38813983
I'm not sure where/how (very new to MDX) .... would you mind updating the code I posted with what you mean?
0
 
LVL 28

Accepted Solution

by:
Ryan McCauley earned 500 total points
ID: 38815002
You should be able to do this:

WITH MEMBER [Measures].[ParameterCaption] AS
             [Accounting Period].[Accounting Period Name].CURRENTMEMBER.MEMBER_CAPTION 
     MEMBER [Measures].[ParameterValue] AS 
             [Accounting Period].[Accounting Period Name].CURRENTMEMBER.UNIQUENAME 
     MEMBER [Measures].[ParameterLevel] AS 
             [Accounting Period].[Accounting Period Name].CURRENTMEMBER.LEVEL.ORDINAL 

SELECT {[Measures].[ParameterCaption],
        [Measures].[ParameterValue],
        [Measures].[ParameterLevel] } ON COLUMNS, 
ORDER( {[Accounting Period].[Accounting Period Name].ALLMEMBERS},
         CDATE([Measures].[ParameterCaption]), desc) ON ROWS 

Open in new window

0
Free Webinar: AWS Backup & DR

Join our upcoming webinar with experts from AWS, CloudBerry Lab, and the Town of Edgartown IT to discuss best practices for simplifying online backup management and cutting costs.

 

Author Comment

by:vbnetcoder
ID: 38818493
ryanmccauley,

When I run that code I get an error:

Parser: The end of the input was reached.
0
 
LVL 28

Expert Comment

by:Ryan McCauley
ID: 38818964
I'm sorry - I missed the FROM statement at the end of your original MDX. Just add it back to the query and it should work:

WITH MEMBER [Measures].[ParameterCaption] AS
             [Accounting Period].[Accounting Period Name].CURRENTMEMBER.MEMBER_CAPTION 
     MEMBER [Measures].[ParameterValue] AS 
             [Accounting Period].[Accounting Period Name].CURRENTMEMBER.UNIQUENAME 
     MEMBER [Measures].[ParameterLevel] AS 
             [Accounting Period].[Accounting Period Name].CURRENTMEMBER.LEVEL.ORDINAL 

SELECT {[Measures].[ParameterCaption],
        [Measures].[ParameterValue],
        [Measures].[ParameterLevel] } ON COLUMNS, 
ORDER( {[Accounting Period].[Accounting Period Name].ALLMEMBERS},
         CDATE([Measures].[ParameterCaption]), desc) ON ROWS 

FROM [MasterCube]

Open in new window

0
 

Author Comment

by:vbnetcoder
ID: 38827301
That worked ... thanks!!
0
 

Author Closing Comment

by:vbnetcoder
ID: 38827306
TY
0

Featured Post

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
As technology users and professionals, we’re always learning. Our universal interest in advancing our knowledge of the trade is unmatched by most industries. It’s a curiosity that makes sense, given the climate of change. Within that, there lies a…
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question