问题
Below is my MDX query
SELECT NON EMPTY
{ [Measures].[Fact Sample Count] } ON COLUMNS,
NON EMPTY
{ (
[Fact Sample].[Sample Reference No].[Sample Reference No].ALLMEMBERS
) } ON ROWS
FROM [LIMSInstCube]
WHERE ( [Dim Material Master].[Material Master ID].&[999] )
So it gives 10 records as my out put. I have a requirement where I have to show the number of records that are returned from the query i.e 10. Can any one please help me how to get the records count.
回答1:
This should get you the count:
NonEmpty
(
{[Fact Sample].[Sample Reference No].[Sample Reference No].ALLMEMBERS},
([Dim Material Master].[Material Master ID].&[999], [Measures].[Fact Sample Count])
).Count
The idea is to get the set of non-empty members from the [Fact Sample].[Sample Reference No].[Sample Reference No]
level for the material master ID
999 which have a non-zero(non-null) fact sample count
.
EDIT : What I created for you is a measure. You have to declare a calculated member(measure) and write the definition there and then access it using the regular SELECT {...} FROM {...} WHERE {...}
construct.
WITH MEMBER Measures.YourCustomizedCountMeasure AS
NonEmpty (
[Fact Sample].[Sample Reference No].[Sample Reference No].ALLMEMBERS,
([Dim Material Master].[Material Master ID].&[999], [Measures].[Fact Sample Count])
).Count
SELECT Measures.YourCustomizedCountMeasure ON 0
FROM [LIMSInstCube]
来源:https://stackoverflow.com/questions/34737975/mdx-query-to-return-the-number-of-records