MDX Query to return the number of records

岁酱吖の 提交于 2019-12-31 05:18:09

问题


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

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!