Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
rainchong7401
Helper III
Helper III

Subtraction Formula

Hi Friends,
Is there a subtraction formula?
I cannot find on the internet or power bi forum. 
Which is quite tough  to achieve the result i wanted.
Kindly assist me guys.

image.png

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @rainchong7401 ,

 

Are you the maximum value minus all other values or from top to bottom, the last row of values minus all the values above?

In the first case, create a measure like this:

Subtract Formula = var _max=CALCULATE(MAX('Table'[Number]),ALLSELECTED('Table'))
var _total=_max*2-CALCULATE(SUM('Table'[Number]),ALLSELECTED('Table'))
return IF(ISINSCOPE('Table'[Number]),SUM('Table'[Number]),_total)

vstephenmsft_0-1672897222835.png

In the second case, you need to create an index column to get the value of the last row and subtract the other values.

Add the index column in Power Query.

vstephenmsft_1-1672897480161.png

vstephenmsft_2-1672897601795.png

Then create a measure.

Subtract Formula 2 = var _maxindex=CALCULATE(MAX('Table'[Index]),ALLSELECTED('Table'))
var _last=CALCULATE(SUM('Table'[Number]),FILTER(ALLSELECTED('Table'),[Index]=_maxindex))
return IF(ISINSCOPE('Table'[Number]),SUM('Table'[Number]),_last*2-CALCULATE(SUM('Table'[Number]),ALLSELECTED('Table')))

vstephenmsft_3-1672897964387.png

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi @rainchong7401 ,

 

Are you the maximum value minus all other values or from top to bottom, the last row of values minus all the values above?

In the first case, create a measure like this:

Subtract Formula = var _max=CALCULATE(MAX('Table'[Number]),ALLSELECTED('Table'))
var _total=_max*2-CALCULATE(SUM('Table'[Number]),ALLSELECTED('Table'))
return IF(ISINSCOPE('Table'[Number]),SUM('Table'[Number]),_total)

vstephenmsft_0-1672897222835.png

In the second case, you need to create an index column to get the value of the last row and subtract the other values.

Add the index column in Power Query.

vstephenmsft_1-1672897480161.png

vstephenmsft_2-1672897601795.png

Then create a measure.

Subtract Formula 2 = var _maxindex=CALCULATE(MAX('Table'[Index]),ALLSELECTED('Table'))
var _last=CALCULATE(SUM('Table'[Number]),FILTER(ALLSELECTED('Table'),[Index]=_maxindex))
return IF(ISINSCOPE('Table'[Number]),SUM('Table'[Number]),_last*2-CALCULATE(SUM('Table'[Number]),ALLSELECTED('Table')))

vstephenmsft_3-1672897964387.png

 

 

Best Regards,

Stephen Tao

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

ribisht17
Super User
Super User

How do you get 34?

I got you can add up to 66

 

Regards,

Ritesh

 

ribisht17
Super User
Super User

Please give a clear explanation.

 

Sub is not a big deal Power BI Measure Sum and Subtract Example - SPGuides

 

Thanks,

Ritesh

Hi Ritesh,
Sum([column]) = 66

What if I want to have subtraction? (Is there a =Sub() formula)
Sub([column]) = 34

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors