如何计算 Power BI 中的累计次数? [英] How to count cumulatively count occurrences in Power BI?

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

问题描述

假设我有一张这样的桌子:

Let's say I have a table like this:

column1   Column2
A         01/01/2020
B         01/01/2020
C         04/01/2020
A         07/01/2020
B         07/01/2020
A         12/01/2020
C         10/01/2020

我要做的是计算 column1 中的值发生了多少次.所以我希望能够以这样的方式结束:

What I am trying to do is count how many times a value in column1 has occurred. So I want to be able to end up with this:

column1   Column2      column3
A         01/01/2020   1
B         01/01/2020   1
C         04/01/2020   1
A         07/01/2020   2
B         07/01/2020   2
A         12/01/2020   3
C         10/01/2020   2

我发现 DAX 可以计算一个值总共出现了多少次,但我似乎找不到如何累计计算它们.提前致谢.

I found DAX to count how many times in total a value occurs but I can't seem to find how to count them cumulatively. Thanks in advance.

推荐答案

逻辑同累积和,只是用 COUNT 代替:

The logic is the same as with a cumulative sum, just with COUNT instead:

column3 =
CALCULATE (
    COUNT ( Table1[column1] ),
    ALLEXCEPT ( Table1, Table1[column1] ),
    Table1[Column2] <= EARLIER ( Table1[Column2] )
)

另请参阅:累积总 DAX 模式

按分组的不同列的累积和日期和过滤方式不同

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

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