小计 <>行的总和 [英] Subtotal <> sum of the rows

查看:7
本文介绍了小计 <>行的总和的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 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]
    )
)

<头>
地区地区小计原尺寸新措施
亚洲错误200400
美洲错误5001000
欧洲错误300300
是的10002000

我试图让第二列的 (400+1000+300) = 1700 而不是 2000.有什么想法吗?

I'm trying to get (400+1000+300) = 1700 for the second column instead of 2000. Any ideas?

推荐答案

对于小计行,选择的值不是Europe";所以它的价值翻了一番.

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
        )
    )

这篇关于小计 &lt;&gt;行的总和的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆