Groups | Blog | Home
all groups > sql server reporting services > november 2004 >

sql server reporting services : Sort in MDX


Markus Krenn
11/23/2004 10:55:06 PM
Hi,
how can I Sort this MDX statement by City

SELECT {[Measures].[Store Sales]} on Columns, {DISTINCT([Store].[Store
City].members)} on Rows FROM SALES

It is used in Reporting Services to fill the City-Paramter with values, in
the Sample-Report MDX_Expression.rdl with DataSource Northwind2000

many thanks
markus
johnE
11/24/2004 12:39:01 PM
Here is the query I use which provides a nice indented list
<<
with Member [Measures].[SupplierUniqueName] as
'[Supplier].[SupplierSKU].currentmember.UniqueName'

member [Measures].[SupplierDisplayName] as
'Space([Supplier].[SupplierSKU].Currentmember.Level.Ordinal * 4) +
[Supplier].[SupplierSKU].Currentmember.Name'

SELECT
{ [Measures].[SupplierUniqueName] , [Measures].[SupplierDisplayName]} on
Columns,
{filter([Supplier].[SupplierSKU].[Supplier].Members,(Measures.[Sales Value]
[quoted text, click to view]
from
Supplier
[quoted text, click to view]
I had to add a filter because we have over 8000 vendors most of which we
don't need to look at. Take the filter out and substitue your dimension
names and you shoudl get what you need.
[quoted text, click to view]
johnE
11/24/2004 12:39:05 PM
If you are selecting from a diminsion I don't think you need distinct.

[quoted text, click to view]
Markus Krenn
11/24/2004 1:29:07 PM
Many Thanks,
I've tried to substitute the dimension to following mdx, but it doesnt work:

with Member [Measures].[SupplierUniqueName] as
'[Store].[Store City].currentmember.UniqueName'

member [Measures].[SupplierDisplayName] as
'Space([Store].[Store City].Currentmember.Level.Ordinal * 4) +
[Store].[Store City].Currentmember.Name'

SELECT
{ [Measures].[SupplierUniqueName] , [Measures].[SupplierDisplayName]} on
Columns,
{[Measures].[Store Sales]} on rows
FROM SALES

error: unknown dimension "[Store].[Store City]"
Whats wrong?
Markus

[quoted text, click to view]
Deepak
11/24/2004 11:21:01 PM
The problem could be that the original example used a hierarchy:
[Supplier].[SupplierSKU], which should be replaced by [Store], not
[Store].[Store City]:

[quoted text, click to view]
with Member [Measures].[SupplierUniqueName] as
'[Store].currentmember.UniqueName'

member [Measures].[SupplierDisplayName] as
'Space([Store].Currentmember.Level.Ordinal * 4) +
[Store].Currentmember.Name'

SELECT
{ [Measures].[SupplierUniqueName] , [Measures].[SupplierDisplayName]} on
Columns,
[Store].[Store City].Members on rows
FROM SALES
[quoted text, click to view]



[quoted text, click to view]
AddThis Social Bookmark Button