Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more.
Get startedGrow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.
I have a table with the following data:
group | field1 | field2 | field3 |
A | 20 | 3 | 8 |
A | 16 | 2 | 5 |
B | 10 | 5 | 5 |
B | 15 | 4 | 2 |
A | 7 | 9 | 1 |
I need to define a measure that performs the subtraction of sum(field1)-sum(field3) when group='A' and sum(field2)-sum(field3) when group='B'. How can I achieve this?
Something in pseudocode like:
sum(if group='A' then field1 else field2)-sum(field3)
With the previous table, the result should be:
(20+16+5+4+7)-(8+5+5+2+1)=52-21=31
Solved! Go to Solution.
Hi,
Please check the below picture and the attached pbix file.
Expected result measure: =
VAR _conditionA =
FILTER ( data, data[group] = "A" )
VAR _conditionB =
FILTER ( data, data[group] = "B" )
RETURN
SUMX ( _conditionA, data[field1] - data[field3] )
+ SUMX ( _conditionB, data[field2] - data[field3] )
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Hi,
Please check the below picture and the attached pbix file.
Expected result measure: =
VAR _conditionA =
FILTER ( data, data[group] = "A" )
VAR _conditionB =
FILTER ( data, data[group] = "B" )
RETURN
SUMX ( _conditionA, data[field1] - data[field3] )
+ SUMX ( _conditionB, data[field2] - data[field3] )
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
User | Count |
---|---|
55 | |
46 | |
18 | |
16 | |
15 |
User | Count |
---|---|
115 | |
42 | |
41 | |
27 | |
22 |