Solved

Renaming an MDX query column headings

Posted on 2004-08-19
6
6,972 Views
Last Modified: 2008-02-07
Hi,

I have an MDX query which returns two columns:

[vwFHPROP_dmnFH].[FH1].[MEMBER_CAPTION]
[vwFHPROP_dmnTime].[All dmnTime].[2004].[8].[13]

How can I rename these columns to more meaningful name, I know in SQL it would be AS 'ColName'. How is it done in MDX?

Thanks.


The MDX query is below:

WITH SET [OlapX%X0_Lst] AS 'DESCENDANTS([vwFHPROP_dmnTime].[All dmnTime].[2004].[8].[13], [vwFHPROP_dmnTime].[Day], SELF_AND_AFTER)' SET [OlapX%X0_Flt] AS '[OlapX%X0_Lst]' SET [OlapX%X0_Prt] AS '[OlapX%X0_Flt]' SET [OlapX%X0_Ord] AS '[OlapX%X0_Prt]' SET [OlapX%Y0_Lst] AS 'DESCENDANTS([vwFHPROP_dmnFH].[All dmnFH], [vwFHPROP_dmnFH].[FH1], SELF)' SET [OlapX%Y0_Flt] AS '[OlapX%Y0_Lst]' SET [OlapX%Y0_Prt] AS '[OlapX%Y0_Flt]' SET [OlapX%Y0_Ord] AS '[OlapX%Y0_Prt]' SET [OlapX%Y1_Lst] AS ' {[vwFHPROP_dmnProposal].[All dmnProposal]} ' SET [OlapX%Y1_Flt] AS '[OlapX%Y1_Lst]' SET [OlapX%Y1_Prt] AS '[OlapX%Y1_Flt]' SET [OlapX%Y1_Ord] AS '[OlapX%Y1_Prt]' SET [OlapX%X0_Fin] AS '{[OlapX%X0_Ord]}' SET [OlapX%Y0_Fin] AS '{[OlapX%Y0_Ord]}' SET [OlapX%Y1_Fin] AS '{[OlapX%Y1_Ord]}' SET [OlapX%X] AS '[OlapX%X0_Fin]' SET [OlapX%Y] AS 'CROSSJOIN([OlapX%Y0_Fin], [OlapX%Y1_Fin])' SELECT NON EMPTY [OlapX%X] ON AXIS(0),  NON EMPTY [OlapX%Y] ON AXIS(1) FROM [vwFHPROP#Active] WHERE ([Measures].[msrCount], [vwFHPROP_dmnProgress].[All dmnProgress])
0
Comment
Question by:DavidDunn
  • 2
  • 2
6 Comments
 

Author Comment

by:DavidDunn
ID: 11871063
I have simplified the query to:

SELECT
NON EMPTY {DESCENDANTS([vwFHProposals_dmnTime].[All dmnTime].[2004].[8].[13], [vwFHProposals_dmnTime].[Day], SELF_AND_AFTER)} ON AXIS(0),  
NON EMPTY CROSSJOIN({DESCENDANTS([vwFHProposals_dmnFinanceHouse].[All dmnFinanceHouse], [vwFHProposals_dmnFinanceHouse].[FinanceHouse1], SELF)},
{{[vwFHProposals_dmnProposal].[All dmnProposal]}}) ON AXIS(1)
FROM [vwFHProposals]
0
 
LVL 15

Expert Comment

by:jdlambert1
ID: 11871252
Try:

SELECT
NON EMPTY {DESCENDANTS([vwFHProposals_dmnTime].[All dmnTime].[2004].[8].[13], [vwFHProposals_dmnTime].[Day], SELF_AND_AFTER)} AS ColName ON AXIS(0),  
NON EMPTY CROSSJOIN({DESCENDANTS([vwFHProposals_dmnFinanceHouse].[All dmnFinanceHouse], [vwFHProposals_dmnFinanceHouse].[FinanceHouse1], SELF)}, {{[vwFHProposals_dmnProposal].[All dmnProposal]}})  AS ColName2 ON AXIS(1)
FROM [vwFHProposals]

Note that the alias doesn't use quote marks, applies to a set, and comes before "ON AXIS"

Also, if you're not aware of it, the new Cube Analysis Add-In for Excel lets you connect to a cube, drag & drop whatever you want to get the results you want, and then you can have it show you the MDX needed to produce those results (from the drop-down menu). Way cool.
0
 

Author Comment

by:DavidDunn
ID: 11871428
Hi,

Thanks for your suggestion. Unfortunately I get the error:
Syntax error in the axis definition:'AS ColName ON AXIS(0),NON EMPTY CROSSJOIN({DESCENDANTS([vwFHProposals_dmnFinanceHouse].[All dmnFinanceHouse], [vwFHProposals_dmnFinanceHouse].[FinanceHouse1], SELF)}, {{[vwFHProposals_dmnProposal].[All dmnProposal]}})  AS ColName2 ON AXIS(1)
FROM [vwFHProposals]'

Any more ideas?
0
 
LVL 15

Accepted Solution

by:
jdlambert1 earned 500 total points
ID: 11872262
Sorry, I mixed Microsoft & non-Microsoft. If you're trying to change the name of the column header in the results, you can't do that with just MDX.

In MDX, there are the 5 fixed aliases for dimensions (ON COLUMN, ON ROWS, etc) and you can use the WITH SET to create aliases that only apply inside the MDX query itself (not to the output).

To control the column header in results, you have several options:
1. Create/change the dimension/measure names in your cube definitions.
2. Open the cube in Excel with Cube Analysis, display the data, disconnect the data from the cube, and manually change the headers (you can use VBA to automate this).
3. Use a third party front-end app that provides this funtionality (expensive).
4. Create your own front-end app with this functionality.
5. ~Haven't investigated it yet, but SQL Server Reporting Services might provide this functionality.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
I have a large data set and a SSIS package. How can I load this file in multi threading?
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

821 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