Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-19-2012, 02:16 PM
56_kruiser 56_kruiser is offline AND function be used as criteria in DB functions? Windows 7 64bit AND function be used as criteria in DB functions? Office 2010 64bit
Novice
AND function be used as criteria in DB functions?
 
Join Date: Nov 2012
Posts: 26
56_kruiser is on a distinguished road
Default AND function be used as criteria in DB functions?

I read some docs that say this: AND and OR functions can be used as criteria in DB functions. It gives this example:

=AND(E4>F9,D7<A5,M3>G1,B1=“FY 2010”)



with the final argument being the result that is displayed (I presume meaning if that above is listed in the criteria, it would resulst in FY 2010 being the criteria).

But I can't seem to find anything that indicates that AND would work like that, or make anything work with it.

Any comments/thoughts?
Reply With Quote
  #2  
Old 11-20-2012, 12:15 AM
Pecoflyer's Avatar
Pecoflyer Pecoflyer is offline AND function be used as criteria in DB functions? Windows 7 64bit AND function be used as criteria in DB functions? Office 2010 64bit
Expert
 
Join Date: Nov 2011
Location: Brussels Belgium
Posts: 2,771
Pecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant futurePecoflyer has a brilliant future
Default

This statement is perfectly valid and will return FALSE or TRUE. What problem do you have?
__________________
Did you know you can thank someone who helped you? Click on the tiny scale in the right upper hand corner of your helper's post
Reply With Quote
  #3  
Old 11-20-2012, 09:49 AM
56_kruiser 56_kruiser is offline AND function be used as criteria in DB functions? Windows 7 64bit AND function be used as criteria in DB functions? Office 2010 64bit
Novice
AND function be used as criteria in DB functions?
 
Join Date: Nov 2012
Posts: 26
56_kruiser is on a distinguished road
Default

Quote:
Originally Posted by Pecoflyer View Post
This statement is perfectly valid and will return FALSE or TRUE. What problem do you have?
Maybe my experimentation with it has been wrong.

The problem that I have is that the criteria in all the examples in the documentation (not using any AND statements in examples), expects a criteria statement, such as B1=FY 2010, not a True or a False value. It is referring to DB functions.

Below is the definition of what Criteria is from the Excel Help:

Quote:
Criteria is the range of cells that contains the conditions you specify. You can use any range for the criteria argument, as long as it includes at least one column label and at least one cell below the column label in which you specify a condition for the column
That is not a True or False value. I've tried entering the AND in the criteria similar to the example and it always returns an error. Again, the document says that the AND and OR functions can be used as Criteria in DB function. It appears to me the document I am reading is wrong.
Reply With Quote
  #4  
Old 11-20-2012, 10:06 AM
Colin Legg's Avatar
Colin Legg Colin Legg is offline AND function be used as criteria in DB functions? Windows 7 32bit AND function be used as criteria in DB functions? Office 2010 32bit
Expert
 
Join Date: Jan 2011
Location: UK
Posts: 369
Colin Legg will become famous soon enough
Default

The helpfile that I have says that you can create AND and OR logic in your criteria by correctly laying out (horizontal and vertical) the criteria in a range.

For example, the helpfile says that to create this logic:
Boolean logic: (Salesperson = "Davolio" OR Salesperson = "Buchanan")
you have to lay out the Salespersons as a list in the same column (there's a picture demonstrating it).

If your source document is the helpfile then I think you've misunderstood "AND" and "OR" boolean logic to mean the AND() and OR() worksheet functions. If your document is something else then point us to it?
__________________
Colin

RAD Excel Blog
Reply With Quote
  #5  
Old 11-20-2012, 10:17 AM
56_kruiser 56_kruiser is offline AND function be used as criteria in DB functions? Windows 7 64bit AND function be used as criteria in DB functions? Office 2010 64bit
Novice
AND function be used as criteria in DB functions?
 
Join Date: Nov 2012
Posts: 26
56_kruiser is on a distinguished road
Default

Quote:
Originally Posted by Colin Legg View Post
The helpfile that I have says that you can create AND and OR logic in your criteria by correctly laying out (horizontal and vertical) the criteria in a range.

For example, the helpfile says that to create this logic:
Boolean logic: (Salesperson = "Davolio" OR Salesperson = "Buchanan")
you have to lay out the Salespersons as a list in the same column (there's a picture demonstrating it).

If your source document is the helpfile then I think you've misunderstood "AND" and "OR" boolean logic to mean the AND() and OR() worksheet functions. If your document is something else then point us to it?
Thanks, yes, using it within a function as you describe would be able to be done, as you say.

I can't specifically point you to the document, as it is printed, and copyrighted. But I think that the document, on this particular topic, is written poorly. It lists it exactly as I wrote in the initial post. And it has the title on the page that it can be used that way in DB functions. Based on being written that way, and based on the fact that earlier in the document they discussed the AND and OR functions, also exampled the same way, I presumed that was what they meant.

I appreciate the feedback. I think the final thought is that they meant as you described, which then does make sense.
Reply With Quote
  #6  
Old 11-20-2012, 10:24 AM
Colin Legg's Avatar
Colin Legg Colin Legg is offline AND function be used as criteria in DB functions? Windows 7 32bit AND function be used as criteria in DB functions? Office 2010 32bit
Expert
 
Join Date: Jan 2011
Location: UK
Posts: 369
Colin Legg will become famous soon enough
Default

Oh, but you can use formulas which return TRUE or FALSE as criteria too. For calculated criteria like this, you must leave the column header blank. For example, in the helpfile:
Quote:
Criteria created as the result of a formula



You can use a calculated value that is the result of a formula as your criterion. Remember the following important points:
  • The formula must evaluate to TRUE or FALSE.
  • Because you are using a formula, enter the formula as you normally would, and do not type the expression in the following way: =''=entry''
  • Do not use a column label for criteria labels; either keep the criteria labels blank or use a label that is not a column label in the range (in the examples below, Calculated Average and Exact Match). If you use a column label in the formula instead of a relative cell reference or a range name, Excel displays an error value such as #NAME? or #VALUE! in the cell that contains the criterion. You can ignore this error because it does not affect how the range is filtered.
  • The formula that you use for criteria must use a relative reference to refer to the corresponding cell in the first row (in the examples below, C7 and A7).
  • All other references in the formula must be absolute references of criteria created as the result of a formula.
So with your formula:
=AND(E4>F9,D7<A5,M3>G1,B1=“FY 2010”)

It should return TRUE if all 3 criteria are met or FALSE if they aren't. When you use it in your criteria range, provided you have followed the rules in the helpfile, it should act as a filter accordingly.
__________________
Colin

RAD Excel Blog
Reply With Quote
  #7  
Old 11-20-2012, 10:28 AM
56_kruiser 56_kruiser is offline AND function be used as criteria in DB functions? Windows 7 64bit AND function be used as criteria in DB functions? Office 2010 64bit
Novice
AND function be used as criteria in DB functions?
 
Join Date: Nov 2012
Posts: 26
56_kruiser is on a distinguished road
Default

Quote:
Originally Posted by Colin Legg View Post
Oh, but you can use formulas which return TRUE or FALSE as criteria too. For calculated criteria like this, you must leave the column header blank. For example, in the helpfile:
Funny. I read that a bit ago, and it didn't sink in. I was focused on a different aspect.

Ok. I may be wrong, but it seems to me that the only case where you would use a criteria that evaluates to True or False is in a situation where you would want to return either All or None of the DB that is being referenced. Would that be right? It seems to me that is all that could happen when using True or False as a criteria.
Reply With Quote
  #8  
Old 11-20-2012, 10:44 AM
Colin Legg's Avatar
Colin Legg Colin Legg is offline AND function be used as criteria in DB functions? Windows 7 32bit AND function be used as criteria in DB functions? Office 2010 32bit
Expert
 
Join Date: Jan 2011
Location: UK
Posts: 369
Colin Legg will become famous soon enough
Default

No, the criteria in your formula is applied to each row in the database. So you can use it to apply criteria across a row in the database which would be difficult or impossible to do by laying out the criteria how I mentioned earlier.

I've attached an example. In it I want to get a sum but only where the name begins with a capital "C". The criteria I'm using is:

=EXACT(LEFT(B3,1),"C")

So the LEFT() function gets the first letter and EXACT() returns TRUE or FALSE depending on if the first letter is a capital "C".

Does that make sense?
Attached Files
File Type: xlsx Book1.xlsx (8.6 KB, 7 views)
__________________
Colin

RAD Excel Blog
Reply With Quote
  #9  
Old 11-20-2012, 11:46 AM
56_kruiser 56_kruiser is offline AND function be used as criteria in DB functions? Windows 7 64bit AND function be used as criteria in DB functions? Office 2010 64bit
Novice
AND function be used as criteria in DB functions?
 
Join Date: Nov 2012
Posts: 26
56_kruiser is on a distinguished road
Default

Quote:
Originally Posted by Colin Legg View Post
No, the criteria in your formula is applied to each row in the database. So you can use it to apply criteria across a row in the database which would be difficult or impossible to do by laying out the criteria how I mentioned earlier.

I've attached an example. In it I want to get a sum but only where the name begins with a capital "C". The criteria I'm using is:

=EXACT(LEFT(B3,1),"C")

So the LEFT() function gets the first letter and EXACT() returns TRUE or FALSE depending on if the first letter is a capital "C".

Does that make sense?

Hi, yes, that all makes sense, and I follow.

I think where the confusion is, is that I was interpreting the statement of returning True or False literally, ie, useing the value True as THE criteria. Not the answer to the criteria.

I'm in synch.

I appreciate your input.
Reply With Quote
  #10  
Old 12-06-2012, 01:28 PM
56_kruiser 56_kruiser is offline AND function be used as criteria in DB functions? Windows 7 64bit AND function be used as criteria in DB functions? Office 2010 64bit
Novice
AND function be used as criteria in DB functions?
 
Join Date: Nov 2012
Posts: 26
56_kruiser is on a distinguished road
Default

Quote:
Originally Posted by Colin Legg View Post
Oh, but you can use formulas which return TRUE or FALSE as criteria too. For calculated criteria like this, you must leave the column header blank. For example, in the helpfile:

So with your formula:
=AND(E4>F9,D7<A5,M3>G1,B1=“FY 2010”)

It should return TRUE if all 3 criteria are met or FALSE if they aren't. When you use it in your criteria range, provided you have followed the rules in the helpfile, it should act as a filter accordingly.
By the way...anyone reading this thread...if you read my original post, the problem and hence my conofusion, is that the third argument -> B1-"FY 2010", is not a third criteria, but the results displayed if the first two arguments, as criteria, is true.

My thought is that the entire example is incorrect, and that the third argument in the AND would be criteria, not results.
Reply With Quote
  #11  
Old 12-06-2012, 02:59 PM
Colin Legg's Avatar
Colin Legg Colin Legg is offline AND function be used as criteria in DB functions? Windows 7 32bit AND function be used as criteria in DB functions? Office 2010 32bit
Expert
 
Join Date: Jan 2011
Location: UK
Posts: 369
Colin Legg will become famous soon enough
Default

Quote:
is that the third argument -> B1-"FY 2010", is not a third criteria, but the results displayed if the first two arguments, as criteria, is true.
Sorry, but that's incorrect.

In this formula:
=AND(E4>F9,D7<A5,M3>G1,B1="FY 2010")

All of the items inside the AND() are criteria.

E4>F9 is criteria1 - a comparison which returns True or False
D7<A5 is criteria2 - a comparison which returns True of False
M4>G1 is criteria3 - a comparison which returns True or False
B1="FY 2010" is criteria4 - a comparison which returns True or False

Then
=AND(criteria1 , criteria2, criteria3, criteria4)

returns True if all four criteria are True, otherwise it returns False.
__________________
Colin

RAD Excel Blog
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Acos, Cos and Sin functions in DAX PowerPivot eramzan Excel 0 03-01-2012 11:32 AM
Using IF and Vlookup functions cpladson Excel 3 12-14-2011 11:57 PM
AND function be used as criteria in DB functions? Assign functions to F1, etc. ibclare Office 4 06-02-2011 03:22 PM
AND function be used as criteria in DB functions? ** Using Functions djreyrey Excel Programming 10 02-08-2011 04:18 PM
Automated Functions?? nickypatterson Outlook 0 08-27-2009 01:50 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 02:16 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft