English 中文(简体)
MDX: How to turn tuples with multiple members into tuples with a single member?
原标题:

I have this MDX query (based on the Foodmart sample database):

SELECT
{[Measures].[Profit]} ON COLUMNS,
{CROSSJOIN([Product].[All Products].Children, [Time].[1997].Children)} ON ROWS
FROM [Sales]

This generates a result like this:

[Product].[Product Family] [Time].[Year] [Time].[Quarter] [Measures].[Profit]
--------------------------+-------------+----------------+-------------------
Drink                     |1997         |Q3              |7203.3445
Drink                     |1997         |Q4              |8005.2245
Food                      |1997         |Q1              |60814.47140000001
Food                      |1997         |Q2              |57323.3736

What I would like to have, is this:

[Product Family],[Year],[Quarter] [Measures].[Profit]
---------------------------------+-------------------
Drink, 1997, Q3                  |7203.3445
Drink, 1997, Q4                  |8005.2245
Food, 1997, Q1                   |60814.47140000001
Food, 1997, Q2                   |57323.3736

I know I can use SetToStr() to serialize the row headers to one string. So now I would like to use that result as rowheader: basically turning each tuple from the original multi-member tuples on the ROW axis into a tuple with just one member, who se value is a concatenation of the original member names. So basically this:

SELECT
{[Measures].[Profit]} ON COLUMNS,
SetToStr(
    {CROSSJOIN([Product].[All Products].Children, [Time].[1997].Children)}
) ON ROWS
FROM [Sales]

...but of course this does not work, because SetToStr() returns a string, not a set. So I need some way to cast this string back to a set, but with only one member.

Is this possible in standard MDX? How? I can rework the resultset after receiving it but I could really use a pure MDX solution to tackle this problem.

最佳回答
WITH MEMBER [Measures].[name] 
AS [Product].currentMember.Name ||  ,  || [Time].CurrentMember.Name
SELECT { [Measures].[name] , [Measures].[Sales]} ON COLUMNS
,      ([Product].Children * [Time].Children)    ON ROWS
FROM   [SteelWheelsSales]
问题回答

暂无回答




相关问题
When is data erased from the OLAP DB?

I am new to OLAP. I understand the table structure and ETL process. I don t understand when data is supposed to be deleted from the fact table. Say I m creating a reporting application for events. ...

IIS 6.0 Application Pool Identity Being Ignored

I am using IIS 6.0 on Windows 2003 in a workgroup, and have created a web which runs in its own pool to connect to a Sqlserver 2005 Analysis Services database using msmdpump.dll. I have set the pool ...

Any scalable OLAP database (web app scale)?

I have an application that requires analytics for different level of aggregation, and that s the OLAP workload. I want to update my database pretty frequently as well. e.g., here is what my update ...

MDX Calculated Member CrossJoin question

I have an MDX query with the following calculated member: with member [Measures].[BBOX] as Count( Filter( CrossJoin([Dim Response].[Response ID].Children, [Dim Question].[Question Text]....

trouble connecting Excel to Analysis Services server

We have an SSAS server with a cube deployed on a server over the WAN.. We are trying to connect to the cube from Excel on various client workstations. The server is not on a domain with the clients. ...

Cant connect to analysis services via excel

I have an analysis services cube in SQL server 2005 which I m connecting to via an excel front end. When I connect via one user its fine, but when I log on to the same machine as another user I get ...

Dimension Security in OLAP Cubes

I have defined dimension security in my OLAP cube by creating roles and assigning users to each roles. Each user in a role can only see the location they belong to. When I browse the cube using a ...

热门标签