Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations cowski on being selected by the Eng-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using and,or functions together in Xcel 1

Status
Not open for further replies.

jetboat

Structural
Joined
Jan 7, 2009
Messages
19
Location
US
Hello, I am trying to use the and, or functions together but the results I am getting from my formula are opposite of what I need. Basically if any combination of cells B4-B7 taken 3 at a time is less than 1.5*B3 its true otherwise false. In my case its true but my formula is saying false. Some guidance would be greatly appreciated!
See attached xcell sheet.
 
I tried downloading your sample file and when opening I get an error stating that it is corrupt. Can you try again?

--Scott
 
Try this. When using AND / OR, you need to give it a logical test, e.g. less than, greater, etc. for each item. Your formula was resulting in a "TRUE" value and comparing it to your 1.5*B3 which is a "FALSE" answer. There may be another way or more efficient way, but I believe it is working.

Joel Berg
 
 http://files.engineering.com/getfile.aspx?folder=38994dff-60dc-4b2d-98a3-99699f8e97d2&file=REVISED_using_or_and_functions_together.xlsx
Break it down to a simple term and see what you get. This will lead you to your error.

AND(B4,B5,B6)<1.5*B3 is your problem. It is not acting as you expect. The first term, AND(B4,B5,B6), does not yield a number. It yields a TRUE or FALSE. Now, you're asking if TRUE or FALSE is less than a numerical value, in this case 1.5*B3, or 18.

You need to say AND(B4<1.5*B3,B5<1.5*B3,B6<1.5*B3). Or, say MAX(B4,B5,B6)<1.5*B3.
 
I think the correct formula to do want he wants is the following:

If(sum(b4:b7)-max(b4:b7)>=1.5*b3,true,false)
 
not quite since he wants any three of B4 to B7 ...
4,5,6; 4,5,7; 5,6,7 ...
if((b4+b5+b6)>1,5*b3,true,if((b4+b5+b7)>1,5*b3,true,if((b5+b6+b7)>1.5*b3,true,false))) ...
i'm not sure of the grammar but maybe ...
if((b4+b5+b6)or(b4+b5+b7)or(b5+b6+b7)>(1.5*b3),true,false)

next the OP will ask for x combinations of y data ...
 
Actually, zelgar's formula is pretty slick. You add up all 4, then subtract out the largest value which will give you the worst case scenario (smallest 3 added together).

A star for elegance!
 
Except that's not what jetboat is trying to do. I believe jetboat is trying to make sure each of the smallest three is less than 1.5*B3, not the sum of the smallest three.
 
Assuming nutte is right (and that's how I read it too), this formula will do the job:

=AND(OR(RANK(B4,B4:B7)=1,B4<B3*1.5),OR(RANK(B5,B4:B7)=1,B5<B3*1.5),OR(RANK(B6,B4:B7)=1,B6<B3*1.5),OR(RANK(B7,B4:B7)=1,B7<B3*1.5))

For each cell in B4 to B7 it checks if the number is either the biggest in that range (rank = 1), or if it is less than B3*1.5.

If that is true for all four cells it returns true, otherwise it returns false.

Doug Jenkins
Interactive Design Services
 
Here's a much neater formula to do the same thing:

=LARGE(B4:B7,2)<B3*1.5

That finds the second biggest value in the range B4:B7 and returns TRUE if it is less than B3*1.5, or FALSE if not.

I had forgotten about the LARGE() and SMALL() functions, and when I looked up the help on RANK() Excel felt no need to remind me.

Did Excel once give a list of related functions whith function help screens, or did I imagine that?

Doug Jenkins
Interactive Design Services
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top