Hi and thanks for responding, the actual data I'm trying to calculate is in microns so I have substituted the values with round numbers for ease.
Please remember that I'm trying to calculate the moving difference of the second value to the first so here are the possible combinations (and formula to calculate for reference) of the values 13 & 18.......
13 to 18 = 5 =ABS(13-18)
18 to 13 = -5 =13-18
-13 to 18 = 31 =ABS((-13)-18)
18 to -13 = -31 =(-13)-18
-13 to -18 = -5 =(-18)-(-13)
To best explain the requirement of this calculation.....
After manufacturing a component, digital measurements are taken using a touch probe, these measurements relate to the axis system of the machine taking the measurements. Upon converting the measurements so they relate to the axis system of the component (to qualify the component as geometrically correct) a deviation from zero (zero being the as designed nominal) is shown for each measure position. If a measured feature on the component was exactly positioned to nominal the value would be zero, if it was out of position it would show either a positive or negative value of the deviation from zero. If after taking the first set of measurements I then subject the component to another manufacturing process (say drill some holes in it) potentially the component features may have moved. If I was to re-measure the component features, I could compare the 2 sets of measurements to each other to analyse how much each component feature had positionally changed from it's original measurements, obviously component features could improve or worsen in relation to zero (nominal) but I want to calculate the difference from its original measurement (could be a positive or negative value).
The method I have used to produce the correct answer is as follows:
1. Test the first value - is it less than zero
2. Test the second value - is it less than zero
3. Test the first value - is it greater than the second
4. Then I use a series of 5 IF AND statements to identify the resultant combination of tests 1 to 3. The possible combinations for the 5 examples above are....
TRUE TRUE FALSE
TRUE TRUE TRUE
FALSE TRUE FALSE
TRUE FALSE TRUE
FALSE FALSE TRUE
5. I then apply 5 IF statements to ensure the right formula is used based on the combination test results.
6. The final step is to test the results of the 5 IF statements for a value.
So my spreadsheet formula looks like this assuming that B2 (13) and C2 (18) are the two values being tested
13
18
=IF(B2>0,TRUE)
=IF(C2>0,TRUE)
=IF(B2>C2,TRUE)
=IF(AND(D2=TRUE,E2=TRUE,F2=FALSE),TRUE) =IF(AND(D2=TRUE,E2=TRUE,F2=TRUE),TRUE) =IF(AND(D2=FALSE,E2=TRUE,F2=FALSE),TRUE) =IF(AND(D2=TRUE,E2=FALSE,F2=TRUE),TRUE) =IF(AND(D2=FALSE,E2=FALSE,F2=TRUE),TRUE)
=IF(G$2=TRUE,ABS(B$2-C$2),M$2)
=IF(H$2=TRUE,C$2-B$2,N$2)
=IF(I$2=TRUE,ABS(B$2-C$2),O$2)
=IF(J2=TRUE,C2-B2,P2)
=IF(K2=TRUE,C2-B2)
I think I need to take a deep breath after that, please have a read and see if you can understand my thought process.
Thanks again for taking the time to reply and please fire more questions back if I havn't explained well enough.