简体   繁体   中英

MDX Including dimension members from outside of hierarchy

How do I select members of a dimension, some of which are within a hierarchy and some aren't? eg, say I have a cities dimension with a hierarchy with state and country, and I want to list all cities in Texas plus London. Something like

SELECT {[Acct Date].[Month].[All Periods]}
        ON COLUMNS
        ,CrossJoin(
             ([Cities].[Country-State-City].&[USA]&[TX].Children, [Cities].[City].&[London])
        ,[Products].[Product])
        OR ROWS
FROM [myCube]
WHERE (
      [Acct Date].[Year].&[2018]
     ,[Measures].[Qty]
)

?

In MDX, in one axis level (in our case the first level of the rows axis, the second being the products), only members from the same hierarchy are allowed. I do not know your cube, hence I am guessing a bit, but probably something similar to the following should work:

CrossJoin(
  Union(
     [Cities].[Country-State-City].&[USA]&[TX].Children, 
     {[Cities].[Country-State-City].&[GB]&[LO].&[London]})
 ,[Products].[Product])
OR ROWS

as in this case all the cities are from the same hierarchy.

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