Solved

Renaming an MDX query column headings

Posted on 2004-08-19
6
6,745 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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Suggested Solutions

Having an SQL database can be a big investment for a small company. Hardware, setup and of course, the price of software all add up to a big bill that some companies may not be able to absorb.  Luckily, there is a free version SQL Express, but does …
I have a large data set and a SSIS package. How can I load this file in multi threading?
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

932 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now