简体   繁体   中英

MDX calculated dimension attribute

Is it possible to create a query scoped dimension attribute (as is done with measures) using the WITH statement.

I'm trying to do something like this:

WITH
MEMBER [Customer].[Has Child At Home] AS
IIF( [Customer].[Number of Cars Owned] > 0,
True,
False

)

And then use the above attribute in a select statement however it is giving me an error saying that the customer dimension has more than one hierarchy and that one needs to be specified.

In this format it requires a hierarchy, to build on your code example [Number of Cars Owned] would need to be a hierarchy:

WITH
  MEMBER [Customer].[Number of Cars Owned].[Has Child At Home] AS
  IIF([Customer].[Number of Cars Owned] > 0, "True", "False")
SELECT
  {[Customer].[Has Child at Home]} ON COLUMNS,
  [DimExample].[AttributeExample].Members ON ROWS,
FROM [CubeExample]

See Creating Query-Scoped Calculated Members (MDX)

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