PDA

View Full Version : Using AND and OR


vamp07
05-23-2005, 03:56 PM
I want to build a search that says give me all items where (FollowUp = yes and there is no DueDate) OR (FollowUp = Yes and Due date is less than or equal to TODAY). Can this be done? I don't see how to construct it without parenthesis.

Thanks

kevina
05-23-2005, 05:51 PM
Yes this can be done, basically indenting in the Search Criteria Grid (in the Advanced Search interface) provides the equivalent of parantheses.

All rows at the same indent level have the same precedence (are grouped together). So to group certain criteria together, simply indent them to the same indent level.

You can indent with the arrow keys in the Item Toolbar or the Move Up/Down/Left/Right entries in the Item menu...

vamp07
05-23-2005, 06:49 PM
Got it working but it's not obvious to me. How would you read this with parens?

------FollowUp=yes
AND Parent Title <> TEMPLATES
------OR DueDate=""
------OR DueDate>=TODAY



What confuses me is that first OR. I switched it to an AND and got the same results. The first AND/OR of an indent is irrelevant?

kevina
05-23-2005, 09:15 PM
If I correctly understand the 1st, 3rd and 4th rows to be indented one level, the following should be the boolean logic employed:

ParentTitle <> TEMPLATES AND (FollowUp=yes or DueDate="" or DueDate>=TODAY)

vamp07
05-23-2005, 09:46 PM
I did not do a good job posting that. 1st and 2nd line are not indented and line 3,4 are indented 1 to the right. I need to show AND but those two first lines are not indented.

Here it is again:

--------FollowUp=yes
AND --Parent Title <> TEMPLATES
---------------OR DueDate=""
---------------OR DueDate>=TODAY

kevina
05-23-2005, 10:16 PM
In that case, the logic used by the search would be:

(FollowUp=yes AND ParentTitle <> TEMPLATES) OR (DueDate="" OR DueDate >= TODAY)

which is the logical equivalent of:

(FollowUp=yes AND ParentTitle <> TEMPLATES) OR DueDate="" OR DueDate >= TODAY

You initially said you wanted to achieve this: "... where (FollowUp = yes and there is no DueDate) OR (FollowUp = Yes and Due date is less than or equal to TODAY)".

To obtain this logic you should construct your search like this:

FollowUp=yes
AND DueDate =""
OR <indent 1> FollowUp=Yes
AND <indent 1>DueDate <= TODAY

or the similar (but equivalent)

FollowUp=yes
AND <indent 1> DueDate NOT EXISTS
OR <indent 1> DueDate = ""
OR <indent 1> DueDate <= TODAY

The AND or OR for the first row at a new indent level determines how the expression represented by that indent level is evaluated related to the other indent levels... Hope that helps. [We'll work on the help file to try to make this clearer for future users!]

Note: The last suggestion also handles the situation where a Followup attribute is assigned (to an Info Item), but no DueDate attribute is even assigned (not sure if this is necessary for your data or not).

vamp07
05-24-2005, 07:50 AM
Thanks Kevina,

1. Two things, The first OR/AND after the indent I don't think works as you stated. I think it is always an AND even if you set it as an OR. I did some tests and changed it to and OR and that should have given me many more results but it gave me the same results as an AND.

2. Most people are going to be confused by this indenting scheme to set up logic. I think if you insert parenthesis into the builder as you indent it might make is easier or just use the space below the tree to show a classic logic expression of what the tree will end up doing. I did not even look in the help because it never occurred to me that indentation might be possible.

kevina
05-24-2005, 09:15 AM
You are correct that an OR relationship of the first criteria row of an indent level is not honored as I explained.

This is a bug and will be addressed in the upcoming minor release. Thanks for reporting it.

kevina
06-06-2005, 01:47 PM
Version 1.3 of Ultra Recall has been released (http://www.kinook.com/UR/download.html), which fixes this reported bug.

vamp07
06-06-2005, 04:16 PM
Thanks!!