计算 Dax 中的出现次数 [英] Count occurrences in Dax

查看:26
本文介绍了计算 Dax 中的出现次数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有下表:

现在,我想对该表应用一些 dax 指令,并将这些数据显示在图表中:

Now, I want to apply some dax instructions to that table, and display this data in a chart:

或者换句话说,如果是第一次出现国家名称,则必须第二次显示12.

Or in other words, I if it is the first time that the Country's name appears, it must show 1 and 2 for the second time.

推荐答案

试试这个来创建一个名为 Occurrences 的计算列:

Try this for creating a calculated column called Occurrences:

Occurrences =
CALCULATE (
    COUNT ( [Pais] ),
    FILTER (
        'Table',
        [Index] <= EARLIER ( 'Table'[Index] )
            && [Pais] = EARLIER ( 'Table'[Pais] )
    )
)

索引必须是每行的增量键.

Index must be an incremental key in each row.

这篇关于计算 Dax 中的出现次数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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