Subtracting two values in degrees, based on a tolerace

macdca

Board Regular
Joined
Sep 28, 2010
Messages
170
I have values in excel (all in degrees), that I would like to flag as outwith or within tolerance levels set. The formula I have is:

=IF(AE51-S51<10,"OutwithTolerance",0)*IF(AE51-S51>10,"OutwithTolerance",0)

So this should tell me that is my planned value (S51) is greater or less than the actual value (AE51) by 10 degrees, I want it flagged as outwith the tolerance. It doesnt seem to work, can anyone help with this?

Also as the values appear to be numbers, where a cell might have 359.2 and the actual value was 2, I want the difference to only be 2.8 rather than the obvious if they were numbers and not degrees, how can I do this in excel??

Thanks
 

Excel Facts

Shade all formula cells
To shade all formula cells: Home, Find & Select, Formulas to select all formulas. Then apply a light fill color.
Isn't it just:-
Code:
=IF(ABS(AE51-S51)>10,"OutwithTolerance","")
or maybe:-
Code:
=IF(OR(AE51-S51)<-10,AE51-S51>10),"OutwithTolerance","")
?
 
Upvote 0
The first one seems to work, does that take into account the fact that the cells are degrees??
 
Upvote 0
The first one seems to work, does that take into account the fact that the cells are degrees??
I've just realised you mean degrees of arc rather than degrees of temperature!

Will the numbers always be around the zero mark? Could they go anywhere near 180?
 
Last edited:
Upvote 0
And will the numbers always be around the zero mark? Could they go anywhere near 180?
 
Upvote 0
As you say, the main problem is that the numbers can lie either side of 360 degrees, so just subtracting them doesn't work. The second problem is that AE51 could be greater than S51 or it could be the other way around.

So what my formula does is find the ABSolute difference between the two values and then in case it's close to 360 it rotates the calculation by 180 degrees and does the calculation at that point of the circle as well. If the calculations fall outside the tolerance at both positions, then "Outwith" is returned. Everything's done MODulo 360 to cope with values which cross the 360-0 boundary.

Try this:-
Code:
=IF(AND([COLOR=red][B]ABS[/B][/COLOR]([COLOR=magenta][B]MOD[/B][/COLOR](AE51,[COLOR=magenta][B]360[/B][/COLOR])-[COLOR=magenta][B]MOD[/B][/COLOR](S51,[COLOR=magenta][B]360[/B][/COLOR]))>10,[COLOR=red][B]ABS[/B][/COLOR]([COLOR=magenta][B]MOD[/B][/COLOR](AE51+[COLOR=blue][B]180[/B][/COLOR],[COLOR=magenta][B]360[/B][/COLOR])-[COLOR=magenta][B]MOD[/B][/COLOR](S51+[COLOR=blue][B]180[/B][/COLOR],[COLOR=magenta][B]360[/B][/COLOR]))>10),"OutwithTolerance",[B]"OK"[/B])

You can change "OK" to "" when you've tested it and are happy it works okay.
 
Upvote 0
One last thing. where the tolerance might be 0.2 for example and the planned position was 0 and it ended up being 359.8, I dont want that to flag as outwith as the allowance is 0.2, and its technically inside that, how can I amend the formuls for this??
 
Upvote 0

Forum statistics

Threads
1,215,001
Messages
6,122,648
Members
449,092
Latest member
peppernaut

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top