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.
Hello, I have some data. I need to calculate a subtraction.
I have a table and I need to calculate a difference (CRE-DET) (in this case it will be 8000-6000) not (8000-0 or 0-6000). How to write DAX formula?
Solved! Go to Solution.
Hi @Analitika
I have seen your another case, they seem to be the same problem.
You can try the following formula to create a new column.
Difference =
VAR _maxCRE =
MAXX( FILTER( 'Table', [ID] = EARLIER( 'Table'[ID] ) ), [CRE] )
VAR _maxDET =
MAXX( FILTER( 'Table', [ID] = EARLIER( 'Table'[ID] ) ), [DET] )
RETURN
IF( [DET] = _maxDET, _maxCRE - _maxDET, BLANK() )
I have the following questions, can you explain them?.
1 you need column or measure?
2 the condition choose 8000 and 6000 to calculate, is it they are the max of current capacity?
3 only display the result in one row or all the rows?
I put my pbix file in the attachment you can reference.
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Analitika
I have seen your another case, they seem to be the same problem.
You can try the following formula to create a new column.
Difference =
VAR _maxCRE =
MAXX( FILTER( 'Table', [ID] = EARLIER( 'Table'[ID] ) ), [CRE] )
VAR _maxDET =
MAXX( FILTER( 'Table', [ID] = EARLIER( 'Table'[ID] ) ), [DET] )
RETURN
IF( [DET] = _maxDET, _maxCRE - _maxDET, BLANK() )
I have the following questions, can you explain them?.
1 you need column or measure?
2 the condition choose 8000 and 6000 to calculate, is it they are the max of current capacity?
3 only display the result in one row or all the rows?
I put my pbix file in the attachment you can reference.
Best Regards
Community Support Team _ chenwu zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
@Analitika , Check the beloe DAX and screen shot also.
That solution not works for me well. I am getting wrong answers.
It's wrong. I am getting
Also my table has more objects with dre and cre each ID.
@Analitika , Try measure like
Sum(Table[CRE]) -Sum(Table[DET])
or
calculate(Sum(Table[CRE]) -Sum(Table[DET]), allexcept(Table, Table[ID]) )
or
calculate(Sum(Table[CRE]) -Sum(Table[DET]), filter(allselected(Table), Table[ID] = max(Table[ID])) )
It's wrong. Subtract is getting like this
Result should be 8000-6000=2000
User | Count |
---|---|
98 | |
76 | |
74 | |
49 | |
26 |