* Edit Custom Query: or function and date

Questions regarding use of any Version of Family Historian. Please ensure you have set your Version of Family Historian in your Profile. If your question fits in one of these subject-specific sub-forums, please ask it there.
Post Reply
avatar
Seeker
Gold
Posts: 28
Joined: 02 Aug 2012 13:26
Family Historian: V7
Location: South Yorkshire

Edit Custom Query: or function and date

Post by Seeker » 02 Aug 2012 13:48

I have downloaded the excellent custom query Name Search and I would like to make some changes in the rows tab. I have tried but I have not had any success:

Change 1: Exclude unless Given Name contains 'First Name' or Nick Name contains 'First Name'
I cannot see how to create an OR function

Change 2: I would like to have an earliest date and a latest date. If I add 'Exclude if %INDI.BIRT.DATE% was earlier than 1800' it excludes all records. However if I run a query with just this line it works perfectly.
I know that there are records which it should find.

ID:6416

User avatar
Jane
Site Admin
Posts: 8442
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Edit Custom Query: or function and date

Post by Jane » 02 Aug 2012 14:00

To use OR you need to wrap the comparisons in the IsTrue() function (there are some examples in the help) and use the ContainsText() function.


With out seeing the whole query it's difficult to check what's wrong with the exclude

avatar
Seeker
Gold
Posts: 28
Joined: 02 Aug 2012 13:26
Family Historian: V7
Location: South Yorkshire

Edit Custom Query: or function and date

Post by Seeker » 02 Aug 2012 16:30

Jane

Thank you for the swift reply. I think I have to create a column which returns true or false. Having looked at the help on the function I have tried
=TextIf(ContainsText(%INDI.NAME:GIVEN_ALL%,'First Name',STD) or ContainsText(%INDI.NAME.NICK%,'First Name',STD),'Found','Not Found')

and this works provided I change 'First Name' to the required value

a) I would like to be able to enter a parameter
b) I am now not sure if I have to use a column because I cannot see how I can get this value into the rows tab. But also I have failed to grasp how I can enter my expression directly into the rows tab.

After leaving the computer for a while, the problem with dates has gone away which is good news for now.

[smile]

User avatar
tatewise
Megastar
Posts: 27088
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Edit Custom Query: or function and date

Post by tatewise » 02 Aug 2012 16:45

The specific Change 1 Row Filter is:
Condition: Exclude unless
Expression: =IsTrue(ContainsText(%INDI.NAME:GIVEN_ALL%,['First Name'],STD) or ContainsText(%INDI.NAME.NICK%,['First Name'],STD))
Operator: is true

The specific Charge 2 Row Filter is:
Condition: Exclude if
Expression: %INDI.BIRT[1].DATE%
Operator: was earlier than
Value: 1800

The other Change 2 Row Filter is as above but
Operator: was later than
Value: 1900

Remember this will only find Individuals that both match the Name criteria and were born after 1800.

avatar
Seeker
Gold
Posts: 28
Joined: 02 Aug 2012 13:26
Family Historian: V7
Location: South Yorkshire

Edit Custom Query: or function and date

Post by Seeker » 11 Aug 2012 13:29

Many thanks for these answers: it now works well. I have decided that I would like to remove a few more possibles.
If I have a photo labelled 'Mary Muggins 1930' and she looks about 70, I can look for any Mary Muggins born between 1830 and 1880 (age 50 to 100 in 1930) and who was still alive in 1930.
Another criterion is that if she was born Mary Muggins but married someone before 1930 then it is unlikely that the photo would be labelled 'Mary Muggins'

I have tried the following expression to remove these cases for the rows but FH will not accept it. Some help on what is incorrect about it would be a help.
Exclude if

=IsTrue(Fieldtext(%INDI%, 'INDI.NAME:SURNAME') matches ['Surname'] and FieldText( %INDI.FAMS[1]>%, 'INDI.FAMS[1]>MARR[1].DATE') was earlier than ['Earliest Date of Interest']))

I will also need to add some additional similar expressions for the other possible marriages.

Is there a reference book / help page with a few more examples available?

User avatar
tatewise
Megastar
Posts: 27088
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Edit Custom Query: or function and date

Post by tatewise » 11 Aug 2012 14:33

The Expression you need is:
=IsTrue((%INDI.NAME:SURNAME% = ['Surname']) and (%INDI.FAMS>MARR.DATE% Family Historian Help > Using Family Historian > Advanced Topics > Understanding Functions > Operators
.

(2) Data References
You do not need to use the FieldText() Function, you can reference the fields directly.
See Help > Family Historian Help > Using Family Historian > Advanced Topics > Understanding Data References.

(3) Data Types
The FieldText() Function Return Type is a  Text Data Type.
So even when the Parameter 2 Data Reference is a DATE, the returned value will be a text string.
So comparing with a Date will NOT work as expected, because they will be compared as text strings.

The Help > Book: 'Getting the Most From Family Historian 5' has a chapter on Custom Queries, but not a great deal on using Functions.
This is considered an advanced topic, so you will need to study the Help > Family Historian Help > Using Family Historian > Advanced Topics section and practice with experimental Queries, starting with one Function at a time until you are comfortable with parameters and data types, then introduce operators to compare Functions.

avatar
Seeker
Gold
Posts: 28
Joined: 02 Aug 2012 13:26
Family Historian: V7
Location: South Yorkshire

Edit Custom Query: or function and date

Post by Seeker » 11 Aug 2012 16:48

Many thanks for your help.

The advanced topics in help was beneficial.

In Understanding Functions the manual says 'it may help to look for an example of a standard query that uses them, and try to copy what it does.' The list of standard functions is so long it is difficult to know which ones to look at.

I have uploaded the query in case it is of use to others.

Thank you for your prompt help.

Post Reply