Solved

Renaming an MDX query column headings

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

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
PL/SQL query 14 51
SQL server 2008 SP4 29 34
Dynamic sql query that use Nvarchar and exceed 4000 characters 22 23
Update in Sql 7 8
In this article—a derivative of my DaytaBase.org blog post (http://daytabase.org/2011/06/18/what-week-is-it/)—I will explore a few different perspectives on which week today's date falls within using Microsoft SQL Server. First, to frame this stu…
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…
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
Via a live example, show how to shrink a transaction log file down to a reasonable size.

762 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

19 Experts available now in Live!

Get 1:1 Help Now