I would like to define a measure that will count dimension members by other dimension and add it as a measure on the cube. Should I create a new measure group with a count of the attribute of dimension or it's better to create a calculated member?
Example on adventureworks: count products by ProductCategory
WITH
MEMBER [Measures].[Number of Products] AS
Count(Existing
[Product].[Product].[Product].Members
)
SELECT
[Measures].[Number of Products] on 0,
{[Product].[Category].Members} ON ROWS
FROM [Adventure Works]
答案 0 :(得分:0)
You haven't given details, but my guess is that your current code will return the count of all products, repeated for each Product Category.
I don't have a working copy of Adventureworks to hand, but if Product is a level one level below Product Category in hierarchy "ProductHierarchy" on the Product dimension, this should work:
WITH MEMBER [Measures].[Number of Products] AS
Count([Product].[ProductHierarchy].CurrentMember.Descendants)
SELECT
[Measures].[Number of Products] ON 0,
{[Product].[Category].Members} ON 1
FROM [Adventure WOrks]