问题
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