按相同 ID 分组的 Power BI Sum 单元格 [英] Power BI Sum cells grouped by same ID

查看:27
本文介绍了按相同 ID 分组的 Power BI Sum 单元格的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何创建一个公式来汇总具有相同 ID 的所有单元格?

How can I make a formula which sums all the cells which have the same ID?

这两列都在同一个表中.我需要一个新列来计算具有相同 ID 的所有小时的总和.

Both of these columns are in the same table. I need a new column which calculates the sum of all the hours with the same ID.

推荐答案

在这种情况下,我会创建一个新的summery table:

In that case, I would create a new summery table:

SummeryTable = 
SUMMARIZE(
    'TableName';
    'TableName'[ID];
    "Time_summed"; SUM('TableName'[TimeColumn])
)

然后,您最终会得到一个表,其中每一行都有不同的 [ID],以及原始数据表中与此 ID 对应的所有小时数的总和.您可以使用它来创建与原始表的关系.

Then you will end up with a table with distinct [ID] on each row and the sum of all hours corresponding to this ID from the original data table. Which you can use to create a relationship with the original table.

EDIT_1:

可以,如果您使用这样的计算列:

Yes you can if you use a calculated column like this:

SumTime = 
VAR thisID = [ID]
RETURN
CALCULATE(
    SUM('TableName'[TimeColumn]);
    ALL('Tablename');
    'TableName'[ID] = thisID
)

这篇关于按相同 ID 分组的 Power BI Sum 单元格的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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