I can't write a MDX query for getting top 10 cities with hierarchy. There's an easy hierarchy of Countries and Cities.
My result should be:
+---------+------------+--------+
| Country | City | Amount |
+---------+------------+--------+
| USA | New York | 123 |
| Germany | Berlin | 65 |
| USA | California | 58 |
| Germany | Munich | 48 |
| Spain | Barcelona | 47 |
| France | Paris | 42 |
| Britain | London | 36 |
| Russia | Moskow | 30 |
| Czech | Prague | 18 |
| Spain | Madrid | 17 |
+---------+------------+--------+
But I get:
+---------+------------+--------+
| Country | City | Amount |
+---------+------------+--------+
| USA | New York | 123 |
| Germany | Berlin | 65 |
| USA | California | 58 |
| Germany | Munich | 48 |
| Spain | Barcelona | 47 |
+---------+------------+--------+
MDX query:
WITH
SET [~ROWS] AS
TopCount(Hierarchize({{[Site].[Country].Members}, {[Site].[City].Members}}), 10, [Measures].[Amount])
SELECT
NON EMPTY {[Measures].[Amount]} ON COLUMNS,
NON EMPTY [~ROWS] ON ROWS
FROM [My_Cube]
Of Course, I understand that Hierarchize({{[Site].[Country].Members}, {[Site].[City].Members}}) return set of tuples, but I don't know, What's the query should be?
Try this, I used adventure works
select {[Measures].[Reseller Order Count]
} on columns,
topcount
(
([Geography].[Country].[Country],[Geography].[City].[City])
,10,[Measures].[Reseller Order Count]
)
on rows
from [Adventure Works]
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.