【问题标题】:Average of distinct account per category每个类别的不同帐户的平均值
【发布时间】:2021-09-24 14:23:15
【问题描述】:

我正在尝试使用 DAX 在 Power BI 中进行计算。 我将逐步解决计算:

  1. 我想先过滤 category1 上的计算
  2. 然后,我想获得每台服务器不同帐户的总和
  3. 有了这些结果,我需要根据以前的结果求平均值。

我知道解释不是最好的,所以这里是我想要的结果,基于这张表:

category1 account server
nobaz account1 server1
baz account2 server1
baz account2 server2
baz account2 server2
baz account4 server3
baz account5 server3

所以在这里我只想选择“baz”,然后计算每个服务器的不同帐户:

  • server1 中有 1 个
  • 1 在服务器 2 中
  • 2 在服务器 3

然后,我想获得每台服务器的平均帐户数(这里是 1,33 ((1+1+2)/3))

谢谢!! :)

【问题讨论】:

    标签: powerbi dax average


    【解决方案1】:
    Measure =
    VAR _accountCount =
        CALCULATE (
            COUNTX (
                GROUPBY ( fct2, fct2[account], fct2[category1], fct2[server] ),
                [account]
            ),
            ALLEXCEPT ( fct2, fct2[category1] )
        )
    VAR _serverCount =
        CALCULATE (
            DISTINCTCOUNT ( fct2[server] ),
            ALLEXCEPT ( fct2, fct2[category1] )
        )
    RETURN
        DIVIDE ( _accountCount, _serverCount )
    

    Only buz Count

    Measure 2 = 
    VAR _accountCount =
        CALCULATE (
            COUNTX (
                GROUPBY ( FILTER(fct2, fct2[category1]="baz"),fct2[account], fct2[category1], fct2[server] ),
                [account]
            ),
            ALLEXCEPT ( fct2, fct2[category1] )
        )
    VAR _serverCount =
        CALCULATE (
            DISTINCTCOUNT ( fct2[server] ),
            ALLEXCEPT ( fct2, fct2[category1] )
        )
    RETURN
        DIVIDE ( _accountCount, _serverCount )
    

    【讨论】:

    • 非常感谢您的回答!!但是,我想要的结果是每个服务器名的不同帐户的平均值,仅将“baz”作为类别的帐户。此外,我需要在不考虑空白服务器的帐户数量的情况下获得这个平均值。你能再帮我一次吗?
    • 仅提供 baz 计数
    猜你喜欢
    • 1970-01-01
    • 2016-03-28
    • 1970-01-01
    • 1970-01-01
    • 2019-03-16
    • 2021-05-10
    • 1970-01-01
    • 1970-01-01
    • 2015-06-01
    相关资源
    最近更新 更多