Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
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] )
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] )
User | Count |
---|---|
15 | |
11 | |
6 | |
6 | |
5 |
User | Count |
---|---|
29 | |
17 | |
11 | |
7 | |
5 |