Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Renaming an MDX query column headings

Posted on 2004-08-19
6
Medium Priority
?
7,596 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 2000 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

A Stored Procedure in Microsoft SQL Server is a powerful feature that it can be used to execute the Data Manipulation Language (DML) or Data Definition Language (DDL). Depending on business requirements, a single Stored Procedure can return differe…
An alternative to the "For XML" way of pivoting and concatenating result sets into strings, and an easy introduction to "common table expressions" (CTEs). Being someone who is always looking for alternatives to "work your data", I came across this …
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how the fundamental information of how to create a table.

721 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