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!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request 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] )
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 11 | |
| 9 | |
| 9 | |
| 6 | |
| 5 |
| User | Count |
|---|---|
| 27 | |
| 22 | |
| 19 | |
| 17 | |
| 11 |