Power BI - 如何获得运行总计并将其添加到您的数据集中 [英] Power BI - How to get running total and adding it along to your set of data
问题描述
我在 Power BI 中有一个示例数据集.我想知道是否可以得到类型 A 的运行总计并将其与原始数据一起添加?
I have a sample data set in Power BI. I was wondering if I could get a running total for Type A and adding it along with the original data?
我有一个例子.
这是数据.
我在 Power BI 中创建了一个矩阵表来查看数据,如下所示:
I created a matrix table in Power BI to view the data like this:
我想知道是否可以将运行总计添加到同一个矩阵表中,以及为类型"设置不同的值.像这样.
如果可能,请告诉我.我知道如何使用 CALCULATE 函数获取运行总计,但我不知道如何将其与原始数据一起添加到表中.
Please let me know if this is possible. I know how to get the running total using the CALCULATE function but I don't know how to add it to the table along with the original data.
推荐答案
您可以告诉它要忽略的行上下文:
You can either tell it what row context to ignore:
RunningCount =
CALCULATE (
SUM ( Table1[Count] ),
FILTER (
ALL ( Table1[Date] ),
Table1[Date] <= MAX ( Table1[Date] )
)
)
或者你可以告诉它保留哪个行上下文(删除所有其他上下文):
or you can tell it which row context to keep (removing all other context):
RunningCount =
CALCULATE (
SUM ( Table1[Count] ),
FILTER (
ALLEXCEPT ( Table1, Table1[Type] ),
Table1[Date] <= MAX ( Table1[Date] )
)
)
在这种情况下,这些应该给出相同的结果.对于这类事情,我更喜欢后者,因为您要指定要分组的内容,而不是您不想保留在分组中的内容.
These should give the same result in this case. I prefer the latter for this sort of thing in general since you're specifying what you're grouping over rather than what you don't want to keep in your grouping.
这篇关于Power BI - 如何获得运行总计并将其添加到您的数据集中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!