Solved

Renaming an MDX query column headings

Posted on 2004-08-19
6
7,152 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

732 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