IN SSAS how to remove null value in distinct count measures

天大地大妈咪最大 提交于 2019-12-10 12:14:27

问题


I have column in fact table .the column in some row has 'Null' value.i have measure based on this column with aggregate function Set to DistinctCount

this measure count null value too. but i don't want to count null value what should i do?


回答1:


Most efficient would be to filter out NULL values in the data source view (using a named query for example). This won't affect performance too much as a distinct count measure is calculated in a separate measure group anyway.




回答2:


One popular solution that works is to count from a view of the table that filters out the nulls. This works, but I would bet that it requires another scan of the fact table.

Another solution is like fighting fire with fire.
Add a computed column that is 0 if it's null and 1 if it's not:

CASE WHEN _DollarsLY IS NULL THEN 0 ELSE 1 END AS _DistinctCountHackLY

Then you can do something like this in a cube calculation:

iif(_DistinctCountHackLY=2 or _DollarsLY=null,_DistinctUPCLY-1,_DistinctUPCLY)


来源:https://stackoverflow.com/questions/14785454/in-ssas-how-to-remove-null-value-in-distinct-count-measures

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