简体   繁体   中英

MDX sorting by dimension (string) value

I am trying to write an MDX query which selects top 100 rows by dimension or measure value.

Fragment on a query

NonEmpty([Domain].[Domain].[Domain].Members , { [Measures].[Total - Domains] } )

I can use topcount and get top 100 rows by "order_count" measure successfully:

topcount(NonEmpty([Domain].[Domain].[Domain].Members , { [Measures].[Total - Domains] } ), 100, [Measures].[order_count])

However, when i try to do that on the dimension value, it does not seem to work properly it seems like it is not doing sorting operation):

topcount(NonEmpty([Domain].[Domain].[Domain].Members , { [Measures].[Total - Domains] } ), 100, [Domain].[Domain].[Value])

I have read that topcount expects numeric expression to sort and my domain value is a string, so I have tried using head() and order(), but I still get incorrect results.

UPDATE: Is seems that i needed to use [Domain].[Domain].properties('Value') instead of [Domain].[Domain].[Value]

SOLVED

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM