IF, OR and AND Nested Formula with a Threshold

beloshi

New Member
Joined
Jul 5, 2018
Messages
29
Hello Excel Gurus,

I have put the Formula to compare the cell based on the cell value using a threshold of ± 30%, in some cell Formula is working fine but in some it is not at all, I cannot figure this out need help.

Here is the Formula I am using;

Code:
Formula =IF(OR(AND(H17=$F$16);AND(H17<=$F$16+($D$153*$F$16));AND(H17<=$F$16-($D$153*$F$16)));TRUE;FALSE)

Where

$D$153 = Threshold % i.e. 0.3
H17= actual cell to compare i.e. -44470
AND $F$16= absolute value to compare with i.e. -790

Here is the screenshot of the formula results which is very weird

w2YW8B7.png


Here is the screenshot of the formula which is working correctly

hroC09c.png



w2YW8B7

Quick help would be much appreciated. Apologies if this question is too stupid to ask here.

BR

BeLoShI
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
You formula does not appear to be written very efficiently (and may actually be incorrecting).
I do not understand why you are using AND at all, all your AND functions only have one argument. You would only use AND or OR when you have more than one thing you want to check within that particular function.

For example, this:
Code:
AND(H17=$F$16)
is only checking one condition, so using AND is totally unnecessary.
It looks like your other two AND statements have the same issue.

I cannot see any of your screenshots. Rather than trying to work with a formula that may be incorrect, can you simply explain exactly what you are trying to do, in plain English? Be sure to include references to all the cells your formula is using in your explanation.
 
Upvote 0
You formula does not appear to be written very efficiently (and may actually be incorrecting).
I do not understand why you are using AND at all, all your AND functions only have one argument. You would only use AND or OR when you have more than one thing you want to check within that particular function.

For example, this:
Code:
AND(H17=$F$16)
is only checking one condition, so using AND is totally unnecessary.
It looks like your other two AND statements have the same issue.

I cannot see any of your screenshots. Rather than trying to work with a formula that may be incorrect, can you simply explain exactly what you are trying to do, in plain English? Be sure to include references to all the cells your formula is using in your explanation.

Hi Thanks for the quick Reply

Here are the screenshots

Formula working correctly

https://imgur.com/hroC09c

Formula Not working

https://imgur.com/w2YW8B7


Actually I am comparing two cells for example in the above screenshot example

Cell A1 = -790

Cell C1 = -44470

C2= -888

In column B1 I have applied the above formula to compare Cell C1, C2 ........ so on and so forth with Cell A1 to see if the value of C1 is either equal to A1 or +30% of C1 or -30% of C1 which is the threshold

Hope this helps to clear my question
 
Upvote 0
I cannot see your images, as my company security blocks all those file and image sharing sites.

But, I think this might do what you want, based on your last example:
Code:
=OR(C1<(A1*(1+0.3)),C1>(A1*(1-0.3)))
On your original example, I think it would look like:
Code:
=OR(H17<($F$16*(1+$D$153)),H17>($F$16*(1-$D$153)))

Note that you do not need to use IF, as AND or OR functions already return True/False be default. So there is no reason to say if True, return True, if False return False (redundant and not necessary).
 
Upvote 0
I cannot see your images, as my company security blocks all those file and image sharing sites.

But, I think this might do what you want, based on your last example:
Code:
=OR(C1<(A1*(1+0.3)),C1>(A1*(1-0.3)))
On your original example, I think it would look like:
Code:
=OR(H17<($F$16*(1+$D$153)),H17>($F$16*(1-$D$153)))

Note that you do not need to use IF, as AND or OR functions already return True/False be default. So there is no reason to say if True, return True, if False return False (redundant and not necessary).

Thanks the above formula is still showing TRUE. I want it to just stay with exactly 30% threshold i.e exactly 0.3 above or below.

Please see the screenshot below for my explanation

https://imgur.com/TEt2nN4
 
Upvote 0
Please see the screenshot below for my explanation
I already mentioned that I cannot see these!

Thanks the above formula is still showing TRUE. I want it to just stay with exactly 30% threshold i.e exactly 0.3 above or below.
If you only want it to show TRUE if it is EXACTLY the 30% threshhold, then just change the > and < signs to =.

And if you want it to be TRUE if they are EXACTLY equal with no threshhold, then just add that first condition back in (like you did in your original formula):
Code:
=OR([COLOR=#ff0000]H17=$F$16[/COLOR],H17=($F$16*(1+$D$153)),H17=($F$16*(1-$D$153)))
 
Last edited:
Upvote 0
Hi,

It gets tricky if you use the >= (greater than or equal) and <= (less than or equal) tests for Both positive And negative values...

i.e.

8 <= 9 is TRUE
-8 <= -9 is Not TRUE

So you would Have to test the values for positive or negative Also.

Here's my suggestion, see if it works for you:


Book1
DEFGH
150.3
16-790
17FALSE-44470
18TRUE-888
19TRUE-790
20TRUE-553
21TRUE-1027
22FALSE-1028
23FALSE-552
24TRUE-554
25
2613
27TRUE11
28FALSE18
29TRUE14
30TRUE13
31FALSE17
Sheet680
Cell Formulas
RangeFormula
G17=H17=MEDIAN(F$16*(1+D$15),H17,F$16*(1-D$15))


Change D$15 to D$153 according to your setup.
 
Last edited:
Upvote 0
Too late to edit.

You may need to replace the commas with semicolons in my formula above for your regional settings.
 
Upvote 0
Hi,

It gets tricky if you use the >= (greater than or equal) and <= (less than or equal) tests for Both positive And negative values...

i.e.

8 <= 9 is TRUE
-8 <= -9 is Not TRUE

So you would Have to test the values for positive or negative Also.

Here's my suggestion, see if it works for you:

DEFGH
150.3
16-790
17FALSE-44470
18TRUE-888
19TRUE-790
20TRUE-553
21TRUE-1027
22FALSE-1028
23FALSE-552
24TRUE-554
25
2613
27TRUE11
28FALSE18
29TRUE14
30TRUE13
31FALSE17

<colgroup><col style="width: 25pxpx"><col><col><col><col><col></colgroup><thead>
</thead><tbody>
</tbody>
Sheet680

Worksheet Formulas
CellFormula
G17=H17=MEDIAN(F$16*(1+D$15),H17,F$16*(1-D$15))

<thead>
</thead><tbody>
</tbody>

<tbody>
</tbody>



Change D$15 to D$153 according to your setup.

Thank You @jtakw for the solution yes you are right its tricky when it comes to values that are negative -8 and -9 or -790 and -44470 in my case. But never the less your solution worked like a charm for me.

Thanks for the efforts @Joe4 and taking out time.

Best Regards

BeLoShI
 
Upvote 0
You're welcome, thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,216,579
Messages
6,131,531
Members
449,654
Latest member
andz

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