Forum Discussion
Substract column with a constant from another column
Hi, I want to calculate as follow:
Minus "Value" for each bucket with "Value" from bucket 1 group by "Division"
| Division | Bucket | Value | Dif |
A | 1 | 7 | 0 (7 - 7) |
| A | 2 | 8 | 1 (8 - 7) |
| A | 3 | 9 | 2 (9 - 7) |
| B | 1 | 10 | 0 (10 - 10) |
| B | 2 | 13 | 3 (12 - 10) |
| B | 3 | 15 | 5 (15 - 10) |
I try to use this DAX, but it return to sum up all "Value" from Bucket = 1 from all Division.
| Division | Bucket | Value | Dif |
A | 1 | 7 | -7 (7 - 17) |
| A | 2 | 8 | -9 (8 - 17) |
| A | 3 | 9 | -8 (9 - 17) |
| B | 1 | 10 | -7 (10 - 17) |
| B | 2 | 13 | -3 (12 - 17) |
| B | 3 | 15 | -2 (15 - 17) |
AN2021
Try this code please:Difference = Table3[Value] - CALCULATE( sum(Table3[Value]), Table3[Bucket] = 1, ALLEXCEPT(Table3,Table3[Division]) )It still works with new dimensions.
See attached file.
If you could share you file so as to have a look at it that would be great
Oh my bad, yeap its work, thanks
8 Replies
- themistoklis
Community Champion
Try the following measure:
Measure3 = VAR __bucket1 = CALCULATE ( SUM ( Sheet1[Value] ), FILTER ( ALLEXCEPT ( Sheet1, Sheet1[Division] ), Sheet1[Bucket] = 1 ) ) RETURN SUM ( Sheet1[Value] ) - __bucket1Workspace attached on this message
- AN2021Frequent Visitor
Hi themistoklis
Its work, but wonder why if I have more column, its not works?
From your example I add 1 column named Dim1
- themistoklis
Community Champion
It still works with new dimensions.
See attached file.
If you could share you file so as to have a look at it that would be great
- AN2021Frequent Visitor
Hi Fowmy
Actually I want to get the "Value" from Bucket = 1, not the Min of "Value". Your solution might work with my example, but in my actual case some "Value" in Bucket = 1 is not the smallest one.