小计行的总和 [英] Subtotal <> sum of the rows
本文介绍了小计行的总和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我是DAX的相对较新手,请多多包涵.用最简单的话来说,我想将非欧洲所有区域的度量值加倍,然后对结果求和.这是一些DAX示例:
I'm a relative neophyte with DAX so bear with me. In the simplest terms, I want to double the measure amount for all regions that are not Europe, then sum the result. Here is some example DAX:
DEFINE
measure Fact[test] = CALCULATE (IF(SELECTEDVALUE('Dim'[Region]) = "Europe", Fact[Revenue],Fact[Revenue] * 2))
EVALUATE(
SUMMARIZECOLUMNS(
ROLLUPADDISSUBTOTAL('Dim'[Region], "RegionSubtotal"),
"Original Measure", Fact[Revenue],
"New Measure", Fact[test]
)
)
Region | RegionSubtotal | 原始措施 | 新措施 |
---|---|---|---|
亚洲 | 错误 | 200 | 400 |
美国 | 错误 | 500 | 1000 |
欧洲 | 错误 | 300 | 300 |
真 | 1000 | 2000 |
我正在尝试为第二列获取(400 + 1000 + 300)= 1700,而不是2000.有什么想法吗?
I'm trying to get (400+1000+300) = 1700 for the second column instead of 2000. Any ideas?
推荐答案
对于小计行,所选值不是欧洲";所以它使价值翻了一番.
For the subtotal row, the selected value is not "Europe" so it's doubling the value.
要解决此问题,您想遍历度量中的区域.像这样:
To fix this, you want to iterate over the regions in your measure. Something like this:
test =
SUMX (
VALUES ( 'Dim'[Region] ),
IF (
'Dim'[Region] = "Europe",
[Revenue],
[Revenue] * 2
)
)
这篇关于小计行的总和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文