Reputation: 115
I want to find the difference between 2 elements with different values and same ID.
I also want to sum all such differences of all the elements in form of a measure.
Please note that the elements may not be arranged in an order. I don't want to create any other table either. I want to create a measure in Power BI called SUM that sums all the differences in the elements.
Thanks in Advance.
Upvotes: 0
Views: 102
Reputation: 8148
Create a measure:
Difference =
VAR Summary =
ADDCOLUMNS (
VALUES ( Table1[ID] ),
"Min Value", CALCULATE ( MIN ( Table1[Value] ), ALLEXCEPT ( Table1, Table1[ID] ) ),
"Max Value", CALCULATE ( MAX ( Table1[Value] ), ALLEXCEPT ( Table1, Table1[ID] ) )
)
RETURN
SUMX ( Summary, [Max Value] - [Min Value] )
Result:
How it works:
Upvotes: 0