Power BI Sum cells grouped by same ID

谁说胖子不能爱 提交于 2019-12-11 15:56:09

问题


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

Edit: 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.


回答1:


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

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

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
)


来源:https://stackoverflow.com/questions/55337848/power-bi-sum-cells-grouped-by-same-id

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!