* Query filter concatenation

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
TMG_refugee
Diamond
Posts: 97
Joined: 14 Nov 2015 15:44
Family Historian: V7

Query filter concatenation

Post by TMG_refugee » 23 Jan 2023 00:42

I am writing a query but I want to have two filters. I created a fact(attribute) called ResearchNote. I wanted to list only those that a not actually exists and then restrict by location so when I go somewhere too do research I can get a list of research items just for that location.

I have tried the research note facility in FH but it does not work well with my workflow thus the creation of a research note that I can place with the individual at the correct location.

In the query Rows I have two statements:

Exclude if %INDI._ATTR-RESEARCHNOTE[1]% is null
Add if %INDI._ATTR-RESEARCHNOTE[1].PLAC>% contains 'Rowley'.

Both work individually but when both are enabled only the first seems to work.
Last edited by tatewise on 23 Jan 2023 10:28, edited 1 time in total.
Reason: Improved Subject

avatar
Gowermick
Megastar
Posts: 1629
Joined: 13 Oct 2015 07:22
Family Historian: V7
Location: Swansea

Re: Query filter concatenation

Post by Gowermick » 23 Jan 2023 07:19

I’m afraid your logic is wrong.

What you are actually doing in your 2nd expression is adding From All Recotds, any record whose note contains rowley, i.e add more records to the resultset to those already found by 1st exoression.

What you need to do is to exclude from the records found by 1st expression, all those records where Place does not contain rowley.
i.e 2nd expression needs to be an exclude statement, not an add


UPDATE
The expressions you need are

Exclude if %INDI._ATTR-RESEARCHNOTE[1]% is null
Exclude Unless %INDI._ATTR-RESEARCHNOTE[1].PLAC>% contains 'Rowley'.

i.e. Exclude all records where Note is Null, then from those, exclude any where PLACE does not contain Rowley
Last edited by tatewise on 23 Jan 2023 10:29, edited 1 time in total.
Reason: Corrected last i.e.
Mike Loney

Website http://www.loney.tribalpages.com
http://www.mickloney.tribalpages.com

avatar
TMG_refugee
Diamond
Posts: 97
Joined: 14 Nov 2015 15:44
Family Historian: V7

Re: Query filter concatenation

Post by TMG_refugee » 23 Jan 2023 18:57

Thanks Mike

that worked perfectly.

Why does the addif get new records where the exclude only works on the previous statements exclude?

User avatar
LornaCraig
Megastar
Posts: 2996
Joined: 11 Jan 2005 17:36
Family Historian: V7
Location: Oxfordshire, UK

Re: Query filter concatenation

Post by LornaCraig » 23 Jan 2023 20:21

Why does the addif get new records where the exclude only works on the previous statements exclude?
What else could they do? Each filter either adds (new records) to the existing results set or excludes some records which are already there.

The special case is the very first filter, where if the first filter is an 'Exclude' (as in your case) the query initially puts all the records in the result set and then applies the Exclude filter. If the very first filter is an 'Add' the query iniitally starts with an empty results set and then applies the Add filter.

After that the filters are applied sequentially. This is from the Help files:

filters.JPG
filters.JPG (33.17 KiB) Viewed 599 times
Lorna

avatar
TMG_refugee
Diamond
Posts: 97
Joined: 14 Nov 2015 15:44
Family Historian: V7

Re: Query filter concatenation

Post by TMG_refugee » 24 Jan 2023 00:00

Thank you Lorna.

Now it is clear to me. I should have seen that myself. Now I can continue with my queries.

avatar
jelv
Superstar
Posts: 366
Joined: 03 Feb 2020 22:57
Family Historian: V7
Location: Mere, Wiltshire

Re: Query filter concatenation

Post by jelv » 25 Jan 2023 10:36

Wouldn't swapping the two lines round have worked? I.e.

Add if %INDI._ATTR-RESEARCHNOTE[1].PLAC>% contains 'Rowley'.
Exclude if %INDI._ATTR-RESEARCHNOTE[1]% is null
John Elvin

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

Re: Query filter concatenation

Post by tatewise » 25 Jan 2023 11:02

Yes, swapping the lines should work but actually it is sufficient to use just one filter:

Add if %INDI._ATTR-RESEARCHNOTE[1].PLAC>% contains 'Rowley'.

That works because if %INDI._ATTR-RESEARCHNOTE[1]% is null then it cannot have a Place field containing 'Rowley' so they are excluded automatically and won't be added.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

avatar
Gowermick
Megastar
Posts: 1629
Joined: 13 Oct 2015 07:22
Family Historian: V7
Location: Swansea

Re: Query filter concatenation

Post by Gowermick » 25 Jan 2023 11:08

At a quick glance, when you think about it, the 1st criteria selects only those whose researchnote.place contains Rowley, therefore none of their researchnotes will be Null, so 2nd test is redundant!
(I’m willing to be corrected :D )

Miketate beat me to it :lol:
Mike Loney

Website http://www.loney.tribalpages.com
http://www.mickloney.tribalpages.com

avatar
jelv
Superstar
Posts: 366
Joined: 03 Feb 2020 22:57
Family Historian: V7
Location: Mere, Wiltshire

Re: Query filter concatenation

Post by jelv » 25 Jan 2023 12:48

I'm wondering why TMG_refugee said the two queries worked individually if his second expression was all that was needed? Wouldn't he have seen that it was giving the results he wanted? Is there some subtlety we are missing?
John Elvin

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

Re: Query filter concatenation

Post by tatewise » 25 Jan 2023 12:59

The two filters will work independently.

Exclude if %INDI._ATTR-RESEARCHNOTE[1]% is null
That lists the 1st instance of a Research Note Fact for every person that has one.
BTW: Does not list 2nd or subsequent instances of that fact.

Add if %INDI._ATTR-RESEARCHNOTE[1].PLAC>% contains 'Rowley'.
As we have decided, that lists every 1st instance of a Research Note that has a Place mentioning Rowley.
That is all that is needed to create the subset of Research Notes.

When the two are run in sequence, the 2nd filter adds nothing since all 1st instance Research Notes are already included.
So adding those that mention Rowley does not add anything that is not already there.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

Post Reply