求助:如何按机器维度计算Total Time聚合并排除描述类字段(DAX)
It looks like you're trying to get the machine-specific Total Time (123 for M1, 456 for M2, etc.) while ignoring filters from Description and Description Time—but your current DAX is returning the grand total of all machines' Total Time instead. Let's fix that.
The Core Issue
Your original expression CALCULATE(SUM('KPI'[Total Time]),ALLSELECTED(Descriptions)) clears filters from the Descriptions table, but it doesn't explicitly preserve the filter context for Machine. This leads to aggregating Total Time across all machines instead of per machine.
Working Solutions
1. Use ALLEXCEPT to Preserve Machine Filters
ALLEXCEPT keeps filters on the specified column(s) and removes filters from all other columns in the table. If Machine is in your KPI table, this is a clean way to lock in the machine context:
Machine Total Time = CALCULATE( SUM('KPI'[Total Time]), ALLEXCEPT('KPI', 'KPI'[Machine]) )
Since each machine has a fixed Total Time value, you can also use MAX or MIN instead of SUM (it will return the same result and may perform slightly better):
Machine Total Time = CALCULATE( MAX('KPI'[Total Time]), ALLEXCEPT('KPI', 'KPI'[Machine]) )
2. Use REMOVEFILTERS to Clear Only Description-Related Filters
If Description and Description Time live in a separate Descriptions table, you can directly remove filters from that table while keeping the Machine filter context intact:
Machine Total Time = CALCULATE( SUM('KPI'[Total Time]), REMOVEFILTERS('Descriptions') )
Again, MAX/MIN works here too for the fixed machine Total Time values.
How This Works
Both methods ensure that when you view rows grouped by Machine, Description, and Description Time, the calculated Machine Total Time column shows the single value for that machine (e.g., 123 for all M1 rows) instead of the grand total of all machines.
内容的提问来源于stack exchange,提问作者Paul Zverev

