* Need query help

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
User avatar
BakerJL75
Famous
Posts: 200
Joined: 14 Dec 2020 11:29
Family Historian: V7

Need query help

Post by BakerJL75 » 08 Mar 2021 17:34

I think understand a simple query, like list everyone who died before 1940. But I can't figure out more complex ones.

I would like a query that lists every ancestor (only ancestors) who has a 1940 census fact (specifically, has a census fact whose date contains 1940). I can make a query to show the ancestors. I can make a query that shows everyone who has a 1940 census event. But I can't make a query that does both. It doesn't seem there is any Boolean logic to the query window. I'm sure I'm missing something, probably obvious, but how do you make a query with AND, OR, NOT, etc.

I'd also like to read (or even watch a video) about queries, but something more advanced that list everyone's death date or something. I've looked but not found much.
Thanks,
Jackie

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

Re: Need query help

Post by tatewise » 08 Mar 2021 18:02

Have you found the FH Help page for the Query Window?
With that window open click the F1 keyboard key to open the associated Help page.
( This works throughout FH and in many other Windows applications as a standard Help shortcut. )

Follow the link to The Rows Tab and it explains how multiple filters are handled.
Sometimes you need a little ingenuity with whether to Add or Exclude and what order to use.

However, sometimes even that won't yield a solution so then you must use the =IsTrue(...) function.
That supports multiple conditions with and and or and not boolean operators.
Have you found the Help page for Operators?

A lot of the above is in the FHUG KB An Overview of Queries with tutorials.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
BakerJL75
Famous
Posts: 200
Joined: 14 Dec 2020 11:29
Family Historian: V7

Re: Need query help

Post by BakerJL75 » 08 Mar 2021 20:33

I had read those, and read them again. I'm not usually this thick headed. Here is what I've tried (only the rows, that is where my problem lies):

Add if %INDI.CENS.DATE% contains text '1930'
Exclude unless an ancestor of [""]

Independently the top one gives me all the people with a 1930 census.
And independently the exclude one gives me a list of ancestors.

But both together are incorrect.

Add if %INDI.CENS.DATE% contains text '1930'
Exclude unless an ancestor of [""]

Gives me 3 ancestors with1930 census and there are many more.

Exclude unless an ancestor of [""]
Add if %INDI.CENS.DATE% contains text '1930'

Gives me ancestors, non-ancestors, 1930 census, 1870 census, etc. I can't even see a pattern to what it outputs.

I've tried variations with %INDI.CENS[1].DATE:YEAR% as well.

I'm sure I've got some logic problem going on with add if/exclude, etc. But haven't figured it out.
I am wondering if the issue is that people have more than one census fact. But then I don't understand why
Thanks,
Jackie

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

Re: Need query help

Post by tatewise » 08 Mar 2021 21:49

Your analysis seems OK up to a point

The idea of having an Add if followed by an Exclude unless is perfect.
It does not matter which Condition goes with which Expression.
So
Add if %INDI.CENS.DATE% contains text '1930'
Exclude unless an ancestor of [""]

is logically the same as
Add if an ancestor of [""]
Exclude unless %INDI.CENS.DATE% contains text '1930'

%INDI.CENS.DATE% contains text '1930' is essentially the same as %INDI.CENS.DATE:YEAR% equals 1930

Be aware that those are only testing the 1st Census event in each Individual, i.e. %INDI.CENS[1].DATE%.
So if an individual has both a 1920 Census and a 1930 Census then that person will NOT be included.
Therefore, I suspect your assertion that "the top one gives me all the people with a 1930 census" is incorrect.
I think it only lists people whose 1st Census was in 1930.

To include everyone who has a 1930 Census could be achieved using:
Add if %INDI.CENS[1].DATE% contains text '1930'
Add if %INDI.CENS[2].DATE% contains text '1930'
Add if %INDI.CENS[3].DATE% contains text '1930'
et al
But there is a shortcut:
Exclude if %INDI.CENS[year=1930]% is null which finds any Census event with a Date in 1930.

Also bear in mind that an ancestor of [""] includes only direct line ancestors.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
BakerJL75
Famous
Posts: 200
Joined: 14 Dec 2020 11:29
Family Historian: V7

Re: Need query help

Post by BakerJL75 » 10 Mar 2021 20:04

Thanks Mike. Got it working. Part of my problem was I output one census year, but it wasn't necessarily 1930 depending on how many census there were. If the column output 1900, then that individual did have a 1930 census, it just wasn't the one displayed.
Thanks,
Jackie

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

Re: Need query help

Post by tatewise » 10 Mar 2021 20:54

You can also use %INDI.CENS[year=1930]% in a Column expression to always display the 1930 Census regardless of what others there may be present.

If you need this query to work for a variety of Census years then you can prompt for the year too but the Column expression is a bit more complex:
=GetField(%INDI%,"%INDI.CENS[year=" . ["Year"] . "]%")

Similarly, the Rows filter expression gets more complex:
Exclude if =GetField(%INDI%,"%INDI.CENS[year=" . ["Year"] . "]%") is null
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

Post Reply