我们来看一个例子

Analysis Services: For Distinct Count measure NULL = 0

If you are to look at the table of values where you want to do a distinct count on the ID column

ID

ColA

NULL

blah

NULL

blah

0

blah

3

blah

1

blah

1

blah

2

blah

2

blah

Within SQL, you will get a value of 4 in which there are four distinct values, 0, 1, 2, 3 and NULL is not counted.

But within Analysis Services, if you were to put a distinct count measure on top of the ID column, you would also get a value of 4 for four distinct values, but those distinct values are 1, 2, 3, and 0.  In this situation, NULL and 0 are the same value.  This is a little bit more apparent if your table had the values of

ID

ColA

1

blah

2

blah

2

blah

3

blah

NULL

blah

Within SQL, you will get a value of 3 (distinct values of 1, 2, and 3) but within AS, you will get a value of 4 (distinct values of 1, 2, 3, and NULL or 0).  There are various philosophical reasons why this is happening ranging from the fact that there are actually quite a few definitions for what NULL is (I really don’t want to get into that) and within AS we’re looking at things from a multi-dimensional point of view (i.e. from the dimension members) hence the exclusion of a NULL value implies exclusion of the rows.  Regardless of the philosophical point of view on this, one should just be aware of this when working with their distinct count measures.

By the way,  if you turn on the NullProcessing property in Sqlserver it will preserve the NULL value – i.e. the first table will have 5 distinct values of 0, 1, 2, 3, and NULL.

如何解决在SSAS中distinct count去数为null的值?

答案是在Sqlserver中从新做一个视图,将事实表中要distinct count的那一列为null的行全部用sql语句的where条件过滤掉。。。请看老外的回答,其中ID这一列就是要在CUBE中distinct count的列:

I had the same problem. I solved it by creating a view with a WHERE condition ISNULL(ID,0) <> 0 and then creating a Distinct Count out of this view

SSAS 度量值中的distinct count局聚合方式会数为null的值的更多相关文章

  1. SSAS维度设计中CustomRollupColumn的用法-自定义聚合方式

          CustomRollupColumn说明:指定包含多维表达式的列,该表达式可用于聚合特性的度量值.这个属性覆盖给定度量值的AggregateFunction的属性. 解释:通常我们的度量值 ...

  2. 数据可视化之powerBI技巧(五)在Power BI中写出优雅的度量值是什么体验?

    之前的文章(采悟:连接表的几个DAX函数,一次全掌握)介绍了产品A的客户与产品B的客户的各种交叉关系,其中最常用的应该是找出A和B的共同客户,以便进行产品关联分析. 之前的思路是计算出两个产品的共同客 ...

  3. 数据可视化之DAX篇(二)Power BI中的度量值和计算列,你搞清楚了吗?

    https://zhuanlan.zhihu.com/p/75462046 对于初学者,总是会把度量值和计算列搞混,我也经常碰到这样的问题,有些星友用文章中的代码总是报错,发给我一看,才知道TA把本来 ...

  4. 数据可视化之powerBI基础(十八)Power BI度量值的格式如何修改?这里有三种方式

    https://zhuanlan.zhihu.com/p/99818030 ​在知识星球遇到的问题中,有不少朋友问如何修改数值型度量值的格式,比如,新建的度量值如何显示为百分比或者千分位等等,这篇文章 ...

  5. 数据可视化之powerBI技巧(十二)学会这几个度量值,轻松获取前N名

    数据中的明细项一般都有很多,可是我们关注的往往只是前几名,所以在报表中只展示关注的部分,就十分常用. 有了上篇(这几个示例,帮你深入理解RANKX排名)关于排名的铺垫,仅显示前N名就简单多了. 依然以 ...

  6. 数据可视化之DAX篇(二十六)Power BI度量值:滚动聚合

    https://zhuanlan.zhihu.com/p/85996745 上一篇文讲了累计聚合,这篇文章继续讲一下滚动聚合,比如常用的MAT计算,Moving Annual Total,滚动年度总计 ...

  7. 微软BI 之SSAS 系列 - 实现Cube 以及角色扮演维度,度量值格式化和计算成员的创建

    在熟悉完下面这三种维度的创建方式之后,就可以开始创建我们的第一个 Cube 了. SSAS 系列 - 自定义的日期维度设计 SSAS 系列 - 基于雪花模型的维度设计 SSAS系列 - 关于父子维度的 ...

  8. 有关Azure存储帐号监视器中的度量值

    在一次故障排错中,发现存储帐号监视器里'成功百分比'(该度量值的源选择的是blob)这个度量值始终是低于100%.引出几个问题: 1. 这个度量值所代表的意义? A: 存储基于REST协议,对服务的访 ...

  9. 在Mondrian Virtual OLAP Cube中观察星座模型多事实表度量值的聚合

    这样设置的Schema文件会怎么样呢?用Saiku预览一下. 如果这时候想同时引用两个项目进行计算就会出问题了.那么这种情况怎么解决? 参考网上一段实现思路 <VirtualCube name= ...

随机推荐

  1. python,tensorflow线性回归Django网页显示Gif动态图

    1.工程组成 2.urls.py """Django_machine_learning_linear_regression URL Configuration The ` ...

  2. 如何面试Web前端开发

    分享一篇HR前端面试心得: 面试前端工程师对我来说是一件非常有意思的事,因为面试过程很大程度上也是自我提升的过程.无论大公司还是小公司,之所以在如何招聘到真正有能力的,前端工程师方面会遇到同样的问题. ...

  3. JavaWeb学习总结(二):Http协议

    一.什么是HTTP协议 HTTP是hypertext transfer protocol(超文本传输协议)的简写,它是TCP/IP协议的一个应用层协议,用于定义WEB浏览器与WEB服务器之间交换数据的 ...

  4. 关于npm构建angular2项目问题

    我在win10系统下用npm构建好angular2项目之后,在命令行下运行 ng serve --open,报一下错误: Unknown browser query 'basedir=$(dirnam ...

  5. HTML中的图片

    在一开始时,Web仅有文本,那真的是很无趣.幸运的是,没过多久网页上就能嵌入图片和其他有趣的内容了.虽然还有许多其他类型的多媒体,但是从地位比较低的<img>元素开始是符合逻辑的,它常常被 ...

  6. LintCode2016年8月22日算法比赛----克隆二叉树

    克隆二叉树 题目描述 深度复制一个二叉树. 给定一个二叉树,返回一个它的克隆品. 样例 给定一个二叉树: 1 / \ 2 3 / \ 4 5 返回其相同结构相同数值的克隆二叉树: 1 / \ 2 3 ...

  7. 学习servlet心得

    1,关于字符编码问题: // resp.setCharacterEncoding("UTF-8");//这个的作用仅仅只是输出字符,不做格式转换成HTML // resp.setC ...

  8. linux整个日志目录查询记录

    在linux下面需要查看整个目录的日志,搜索用户的一个行为.因为不知道具体是那一天,一个个的查询也可以,但是太麻烦.可以用过下面的命令来实现: rep -iRl  "关键字" ./ ...

  9. centos7安装lua语言环境

    Linux 上安装 Lua 安装非常简单,只需要下载源码包并在终端解压编译即可. 官网地址:http://www.lua.org/download.html 我这里安装的是:lua-5.3.0.tar ...

  10. 为exchange 2010 owa 添加验证码

    微软给了exchange owa页面加固的方案,如有需要,请查看. https://partnersupport.microsoft.com/zh-hans/par_servplat/forum/pa ...