* Problem Querying Census Sources

Homeless Posts from the old forum system
Locked
avatar
oldtimer47
Diamond
Posts: 56
Joined: 23 Dec 2008 07:01
Family Historian: None

Problem Querying Census Sources

Post by oldtimer47 » 01 Jan 2012 22:01

Happy New Year everyone

I'm trying to write a query to show all the 'Census Source Where within Source' entries that begin with a particular reference for all census entries for a particular year. I have entry fields (Labels) for the year of interest and the start characters of my reference. First snag is that this might be the first census entry or even the 8th census entry. I can assemble all the records that have a census entry for that year by doing the following.

Add IF %INDI.CENS[1].DATE:YEAR% WAS ON ['Year'}
(and so on)
Add IF %INDI.CENS[8].DATE:YEAR% WAS ON ['Year'}

I then try to exclude records whose 'where within source' don't begin with my reference string.

EXCLUDE UNLESS %INDI.CENS[1].SOUR[1].PAGE% BEGINS WITH ['Reference']
and so on to
EXCLUDE UNLESS %INDI.CENS[8].SOUR[1].PAGE% BEGINS WITH ['Reference']

However this gives me no records at all. I Have tried it the other way round, selecting the reference strings first then excluding the years that don't match with the same effect.

I'm struggling to see the combination of logic that will allow thorough the people with varying numbers of census entries only one of which might match my year and 'where within' check. Maybe I am trying to do too much in one query.

I look forward to any suggestions.

Many Thanks
Peter

ID:5744

User avatar
PeterR
Megastar
Posts: 1129
Joined: 10 Jul 2006 16:55
Family Historian: V7
Location: Northumberland, UK

Problem Querying Census Sources

Post by PeterR » 01 Jan 2012 22:50

If you have version 4.1.3, you can use a Fact Query which would be much simpler.  The Rows filters could be:
Image

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

Problem Querying Census Sources

Post by tatewise » 01 Jan 2012 23:22

Here are a few pointers, and you still get nowhere post again.
(1)
See the Knowledge Base advice on Creating a Query at
http://www.fhug.org.uk/wiki/doku.php?id ... ng_a_query
(2)
One of the tips in that advice is:
'If you are searching for a Fact that often occurs more than once per Individual, such as Census ... then a Query Type of Fact will probably be more suitable.'
These avoid the CENS[1] thru CENS[8] complexity.
Think about Exclude unless =FactName(%FACT%) begins with 'Census' and a filter on %FACT.DATE%.
But Fact Queries are only available in FH V4.
For Fact Queries take note of the further advice regarding the Fact Owner.
(3)
In the same way you need to cope with CENS[1] thru CENS[8] you need to cope with SOUR[1] thru SOUR[n] if more than one Citation per Census Fact.
(4)
Rather than BEGINS WITH ['Reference'], which only tests the very beginning of the PAGE, you need something like Add if =GetLabelledText(%FACT.SOUR[1].PAGE%, ”Reference:”) begins with 'RG12'
Repeat this for SOUR[1] thru SOUR[n].
Then if necessary use Exclude unless =FactName(%FACT%) begins with 'Census'.

avatar
oldtimer47
Diamond
Posts: 56
Joined: 23 Dec 2008 07:01
Family Historian: None

Problem Querying Census Sources

Post by oldtimer47 » 02 Jan 2012 16:56

PeterR and tatewise

Thanks for your suggestions - I've not had to tangle with Fact queries much up to now but your suggestions led me to implement the following. I've written it as it appears in the boxes on the bottom of the filter page.

First ROW with a Label (entry field) 'Source to Check'

Add if
%FACT.SOUR[1]>%
is

When run this asks for the source I want to check (say 1911 UK Census) and it finds all Facts referencing this source  

Second Row

Exlude unless
=FactLabel(%FACT%)
matches
Census

When run this excludes all but the Census entries which only ever have 1 source reference so I don't have to worry about SOUR[1] to SOUR[N] it gives me what I need to see, all the Census entries for a year with their source reference.

Thanks again for the guidance and inspiration
Peter

P.S. Why I want to do this is interesting - one of those 'I wish I had done things differently from the start' moments. When I started I didn't use the full Census reference in the 'Where within Source' - I used my own sequential number. This is fine until you need to share information, they then really need the 'proper' reference. So I have just started editing the Gedcom file to replace these references and needed this query to check that I was not messing things up.

Locked