使用 Dax 将空白值替换为零 [英] Replacing Blank values with Zero using Dax
本文介绍了使用 Dax 将空白值替换为零的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想用零替换空白值,为此我在表格模型中创建了一个度量,该度量的定义是:
I want to replace blank values with zero, for this i have created a measure in tabular model, the definition of that measure is :
Test:=if (
calculate (
sum ( quantity ),
flag = 1,
title = "WEEKS"
) = blank (),
0,
calculate (
sum ( quantity ),
flag=1,
title = "WEEKS"
)
)
虽然它工作得很好,但是当我用某些维度拖动这个度量时,它会增加行数.
Although it works fine, but when i drag this measure with some dimensions it increases the number of rows.
+-------------+-------------+------+
| Dimension A | Dimension B | Test |
+-------------+-------------+------+
| A | C | 0 |
| B | X | 0 |
| A | X1 | 0 |
| B | X1 | 0 |
| A | G | 0 |
| A | D | 0 |
+-------------+-------------+------+
它增加了行,例如,有一个笛卡尔,当我删除 if 条件时,它就可以正常工作.
It increase the rows like, there is a Cartesian, and when i remove the if condition it just works fine.
+-------------+-------------+------+
| Dimension A | Dimension B | Test |
+-------------+-------------+------+
| A | C | 0 |
| B | X | 270 |
| A | X1 | 101 |
| B | X1 | 44 |
| A | G | 12 |
| A | D | 10 |
+-------------+-------------+------+
那么可能是什么原因,我只是想用零替换空白值.
So what could be the reason, I simply want to replace blank values with zero.
推荐答案
如果你想将blank()的值改为零,只需在计算的末尾添加一个0即可:
If you want to change blank() values with zero, just add a 0 at the end of you calculate:
Test:=
calculate (
sum ( quantity ),
flag = 1,
title = "WEEKS"
) + 0
这篇关于使用 Dax 将空白值替换为零的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文