Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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
Check out the July 2025 Power BI update to learn about new features.
User | Count |
---|---|
73 | |
72 | |
38 | |
31 | |
26 |