Search code examples
sql-server-2008-r2ssasmdx

Distinct count to exclude NULL


Is there a way to create a calculated measure that can do a distinct count, but excluding the null values? For example, if I have: 10, 20, 20, null; the distinct count is 3, but can I have the answer as 2?


Solution

  • Thank you for all the answers. However, here I found a solution that works best for my need: http://richardlees.blogspot.com/2008/10/alternative-to-physical-distinct-count.html

    By creating a Calculated Member using the following:

    count(nonempty({[DimName].[HierarchyName].[LevelName].members-[DimName].[HierarchyName][All].UNKNOWNMEMBER},[Measures].[MyMeasure]))