Difference between revisions of "Example filters"

From Gramps
Jump to: navigation, search
m (Introduction: link the what-rule-in-which-category list)
(39 intermediate revisions by 10 users not shown)
Line 1: Line 1:
 +
{{languages|Example filters}}
 +
 
A collection of examples of filters.  
 
A collection of examples of filters.  
  
[[Category:GRAMPS Examples]][[Category:Filters]]
+
==Introduction==
 +
For more info, see [[Filter]] and also [[Gramps_{{man version}}_Wiki_Manual_-_Filters|the wiki manual on Filters]].
 +
When creating custom filters, always make sure you have the [[Gramps_{{man version}}_Wiki_Manual_-_Gramplets#Filter|Filter Gramplet]] in the [[Gramps_{{man version}}_Wiki_Manual_-_Main_Window#Bottombar_and_Sidebar|sidebar]] visible.  This allows testing the filter on real data before putting the filter in general use.  Test each filter individually... don't set up a 2nd stage filter until the 1st stage has been tested. To test: in the Filter tab of the sidebar, select the custom filter you made; then click the {{man button|Find}} button.
 +
 
 +
'''Create a custom filter with the following steps:'''
 +
<!--
 +
* {{man button| {{icon|stock_add}}}}&nbsp;{{man tooltip|Add a new filter}}
 +
:shows the {{man label|Define filter}} dialog and adds a new (as yet unnamed) custom filter framework.
 +
* {{man button| {{icon|stock_edit}}}}&nbsp;{{man tooltip|Edit the selected filter}}
 +
:opens the {{man label|Define filter}} dialog and loads your existing custom filter for editing.
 +
* {{man button|Clone}}&nbsp;{{man tooltip|Clone the selected filter}}
 +
:makes an exact copy of the selected filter
 +
* {{man button|Test}}&nbsp;{{man tooltip|Test the selected filter}}
 +
:brings up the {{man label|Filter Test}} results dialog containing a list of matches following a successful test. If the filter test is invalid, an error may be shown instead.
 +
* {{man button| {{icon|stock_remove}}}}&nbsp;{{man tooltip|Delete the selected filter}}:
 +
:removes the selected filter from the Gramps collection of custom filters.
 +
{{-}}
 +
-->
 +
* Click on {{man menu|Edit}} in the menu bar to display the drop-down list
 +
: The last item is the {{man menu|____ Filter Editor}} and it is contextual, changing the filter editor to only show filters for the category of the current View
 +
* Click on the {{man menu|Filter Editor}}
 +
* Click on {{man label|Filter Editor}} {{man button| {{icon|stock_add}}}}&nbsp;{{man tooltip|Add a new filter}} to start creating a new filter
 +
* Give your filter a unique '''name'''
 +
* Click on {{man label|Define Filter : Rule List}} {{man button| {{icon|stock_add}}}}&nbsp;{{man tooltip|Add another rule to the filter}}  to see the filter rules ([[Gramps_{{man version}}_Wiki_Manual_-_Filters#Which_filters_in_which_Category.3F|limited to those available in the current View]])
 +
* Select an appropriate filtering '''rule'''
 +
 
 +
* Add further rules as needed
 +
 
 +
* Select the appropriate {{man label|Define Filter : Options}} pop-up menu item to define how the rules interact. ''The [[man menu|All rules must apply}} option is selected by default.'' This is only necessary when there are multiple rules.
 +
* Click on the {{man label|Define Filter}} {{man button| OK}}
 +
* Click on the {{man label|Filter Editor}} {{man button| Close}}  ''Note that new custom filters (or changes) only take effect after closing the Filter Editor.''
 +
 
 +
 
 +
There are rules to allow you to use filters defined for another View. In this way you can build up complex filtering involving several Views.
 +
 
 +
{{man warn|Custom Filters are resource hungry|Very large databases may encounter resource limitations when handling some complex filters}}
 +
 
 +
 
 +
Most of the following examples appeared on the Gramps-Users mailing list in response to posts from users and cover Gramps versions 3.4.x to 4.1x
 +
 
 +
 
 +
----
 +
 
 +
== Construction of custom filter examples ==
 +
 
 +
 
 +
 
 +
      Please note these conventions for the construction of Filters:
 +
 
 +
                              '''''<Viewname> Filter Editor'''''.................Editor for this particular View
 +
'''''Filter <filtername>:'''''...........................................................................................................Name of new filter
 +
  <rule name> ........................................................Filter rule selected
 +
 
 +
  OR
 +
 
 +
  <rule group name> =>
 +
        <selected rule name> ..........................................Filter rule selected from a drop-down group of rules
 +
 
 +
'''Option selected''' ................................................................................................................. All/At least one rule must be obeyed
 +
 
 +
'''Use regular expressions''' ................................................................................................. Blank if not required
 +
 
 +
'''<Run Filter <filtername> in <Viewname> View>''' .....................................................Where to run the new filter
 +
 
 +
 
 +
 
 +
----
 +
 
 +
----
 +
 
 +
----
 +
 
 +
 
 +
=='''''1-stage FILTERS'''''==
 +
 
 +
 
 +
 
 +
 
 +
                             
 +
=== Example 1. All sources that have no repository ===
 +
 
 +
                                          '''''Source Filter Editor'''''
 +
'''''Filter A:'''''
 +
General filters=>
 +
    Sources with <count> Repository references; Number of instances:="1"; Number must be:="lesser than"
 +
''OR''
 +
    Sources with a reference count of <count>; Reference count must be:= "lesser than"; Reference count:="1"
 +
 
 +
'''All rules must apply'''
 +
 
 +
'''<Run Filter A> in Source View'''
 +
 
 +
 
 +
----
 +
 
 +
 
 +
                             
 +
=== Example 2. All individuals with no name ===
 +
 
 +
''Comment: In Person View, click on the Name column to get the names in alphabetical order. All blank surnames will be at the top of the list''
 +
 
 +
                  The following filter will display '''only''' the blank given names and/or surnames
 +
 
 +
                                          '''''Person Filter Editor'''''
 +
'''''Filter A:'''''
 +
    General filters=>
 +
          People with the <name>; Given Name:=^$; Full Family Name:=^$
 +
 
 +
'''Use regular expressions'''
 +
 
 +
'''All rules must apply'''
 +
 
 +
'''<Run Filter A> in Person View'''
 +
 
 +
 
 +
----
 +
 
 +
                             
 +
=== Example 3.  All female descendants of Joan Doe ===
 +
 
 +
                                          '''''Person Filter Editor'''''
 +
'''''Filter A:'''''
 +
Descendant filters=>
 +
      Descendants of <person>: <''here find the ID of Joan Doe''> ; Include original person
 +
General filters=>
 +
      Females
 +
 
 +
'''All rules must apply'''
 +
 
 +
'''<Run Filter A> in Person View'''
 +
 
 +
 
 +
----
 +
 
 +
----
 +
 
 +
----
 +
 
 +
 
 +
=='''''2-stage FILTERS'''''==
 +
 
 +
                             
 +
=== Example 1. All people with only one parent recorded ===
 +
 
 +
                                          '''''Person Filter Editor'''''
 +
'''''Filter A:'''''
 +
    General filters=>
 +
          Persons with the <name>; Given name:="(^$|[uU]known)"; Full Family Name:="(^$|[uU]known)"
 +
 
 +
'''**Use regular expressions**'''
 +
 
 +
'''All rules must apply'''
 +
 
 +
 
 +
'''''Filter B:'''''
 +
    Family filters=>
 +
          Children of <filter> match; Filter name:="B"
 +
 
 +
'''All rules must apply'''
 +
 
 +
 
 +
'''THEN <Run Filter B> in Person View'''
 +
 
 +
''Comment: If both parents are unknown you probably won't have any gramps ID assigned for them''
 +
 
 +
 
 +
----
 +
 
 +
 
 +
                               
 +
=== Example 2. Individuals with siblings named “John” ===
 +
 
 +
                                          '''''Person Filter Editor'''''
 +
'''''Filter A:'''''
 +
    General filters=>
 +
          People with the <name>: Given Name:="John"
 +
 
 +
'''All rules must apply'''
 +
 
 +
'''''Filter B:'''''
 +
    Family filter=>
 +
          Siblings of <filter> match: Filter name:="A”
 +
 
 +
'''All rules must apply'''
 +
 
 +
 
 +
'''THEN <Run Filter B> in Person View'''
 +
 
 +
 
 +
----
 +
 
 +
 
 +
                               
 +
=== Example 3.“Timeline” of all people associated with a particular place  ===
 +
 
 +
                                          '''''Place Filter Editor'''''
 +
'''''Filter A:'''''
 +
    General filters=> 
 +
          Places matching the parameters ;Name : <''here insert name of place''>
 +
 
 +
'''All rules must apply'''
 +
                                          '''''Event Filter Editor'''
 +
'''''Filter B:'''''
 +
    General filters=> 
 +
          Events matching the place filter: Place filter name:=”A”
 +
 
 +
'''All rules must apply'''
 +
 
 +
 
 +
'''THEN <Run Filter B> in Events view'''
 +
 
 +
''Configure the View to show columns for Type, Description, Date, Place.''
 +
'' Order the items by Date to get a timeline.''
 +
 
 +
 
 +
OR Alternative 2:
 +
                                            '''''Event Filter Editor'''
 +
'''''Filter A:'''''
 +
    General filters=> 
 +
          Events with data : Place:= <''here insert placename''>
 +
''Comment: if the Event type default is "Birth"., just delete it''
 +
 
 +
'''All rules must apply'''
 +
 
 +
 
 +
'''THEN <run Filter A> in Events View'''
 +
 
 +
 
 +
''For an ordered list of the people '''add''' the following filter:''
 +
                                            '''''Person Filter Editor'''''
 +
'''''Filter B:'''''
 +
    General filters=> 
 +
          Persons with events matching the events filter: Events filter name:= "A".
 +
 
 +
'''All rules must apply'''
 +
 
 +
 
 +
'''THEN <run Filter B> in Person View'''
 +
 
 +
 
 +
----
 +
 
 +
 
 +
 
 +
                               
 +
=== Example 4. All marriage events on the ancestral tree dated after 1837 for a named individual ===
 +
 
 +
                                          '''''Person Filter Editor'''''
 +
'''''Filter A:'''''
 +
    Event filters=>
 +
          People with the personal <event>; Personal event:= Marriage; Date:= after 1837
 +
    Event filters=>
 +
          People with the family <event>; Family event:= Marriage; Date:= after 1837
 +
 
 +
'''**At least one rule applies**'''
 +
                                           
 +
'''''Filter B:'''''
 +
    General filters=> 
 +
          People with the name; <''here insert name of individual''>
 +
    General filters=>
 +
          People matching the <filter>; Filter name:=”A”.
 +
 
 +
'''All rules must apply'''
 +
 
 +
 
 +
'''THEN <run Filter B> in Person View'''
 +
 
 +
 
 +
----
 +
 
 +
 
 +
 
 +
                             
 +
=== Example 5. All persons called "serge" having some connection with London ===
 +
 
 +
                                          '''''Event Filter Editor'''''
 +
'''''Filter A:'''''
 +
    General filters=>
 +
          Events with <data>: Place:="London"
 +
 
 +
'''All rules must apply'''
 +
                                          '''''Person Filter Editor'''''
 +
'''''Filter B:'''''
 +
    General filters=>
 +
          Persons with events matching the <event filter>: Event filter name:= "A"
 +
    People with the <name>: Given name:="serge"
 +
 
 +
'''All rules must apply'''
 +
 
 +
 
 +
'''THEN <run Filter B> in Person View'''
 +
 
 +
 
 +
 
 +
''Comment1: There is no way of going between people and places except by way of events they were involved in at those places''
 +
 
 +
''Comment2: What looks like a minor bug appears when Person filtering on names: a few extraneous individuals appear.''
 +
''They are spouses, included because their married name (or occasionally spouse) is recorded in the database as their Alternative Name''
 +
 
 +
 
 +
 
 +
----
 +
 
 +
 
 +
 
 +
 
 +
                             
 +
=== Example 6. Obtain a ‘focused’ descendant chart containing only a subset of the people ===
 +
 
 +
''Select the subset by tagging manually in your direct ancestral line up from your living relative. Call the tag, say, LINE 1.''
 +
 
 +
                                          '''''Person Filter Editor'''''
 +
'''''Filter A:'''''
 +
    General filters=>
 +
          People with the <tag>; Tag:="LINE 1"
 +
 
 +
'''All rules must apply'''
 +
 
 +
'''''Filter B:'''''
 +
    Family filters=>
 +
          Children of <filter> match: Filter name:="A"
 +
    Family filters=>
 +
          Spouses of <filter> match: Filter name:="A"
 +
    Family filters=>
 +
          Siblings of <filter> match: Filter name:="A"
 +
 
 +
'''**At least one rule must apply**'''
 +
 
 +
 
 +
'''THEN <run Filter B> in Person View''' to display the “focussed” tree
 +
 
 +
''OR:''
 +
  ''Reports=> Graphs=> Relationship Graph=> Report Options=> Filter "B"'' to obtain a chart. Save as SVG for further manipulation
 +
''OR:''
 +
  ''Family Trees=> Export=> Forward=> select Gramps XML package=> Forward=> Person Filter.''
 +
  Click the drop-down list and ''select filter B'' to save the filter results as another family tree.
 +
  Name and export that gpkg; then you can create a new family tree and import the gpkg back into it.
 +
 
 +
 
 +
----
 +
 
 +
 
 +
 
 +
                             
 +
=== Example 7. All people related to me but not my wife ===
 +
 
 +
                                          '''''Person Filter Editor'''''
 +
'''''Filter A:'''''
 +
    Ancestral filters=>
 +
          Ancestors of <person> ID:= <here find YOUR ID>; Inclusive:=0  ''i.e.note: don't include yourself''
 +
 
 +
'''All rules must apply'''
 +
 
 +
 
 +
'''''Filter B:'''''
 +
    Descendant filters=>
 +
          Descendant family members of <filter> match; Filter name:="Filter A"
 +
 
 +
'''All rules must apply'''
 +
 
 +
 
 +
'''THEN <Run Filter B> in Person View'''
 +
 
 +
''Comment: note the difference between the UP filter ("Ancestors") which is '''restrictive'''''
 +
''and the DOWN filter ("Descendant family members of filter) which is '''inclusive'''.''
 +
The former keeps the line of relationship away from the wife; the latter brings in your own in-laws
 +
("Matches people that are descendants or the spouse of anybody matched by the filter")
  
{{languages|Example filters}}
+
''Comment 2: the filter falls down on  people who are not strictly connected to you by marriage but only indirectly''
 +
i.e. people who were married at some time to one of your in-laws, i.e.."in-laws of in-laws".
 +
 
 +
''If you want to incorporate those links as well, add a further filter as follows:''
 +
 
 +
'''''Filter C:'''''
 +
    Descendant filters=>
 +
        Descendant family members of <filter> match; Filter name:="Filter B"
 +
 
 +
'''**At least one rule must apply**'''
 +
 
 +
 
 +
'''THEN <Run Filter C> in Person View'''
 +
 
 +
''Comment 3: you can widen the reach of the links further by adding more filters in the same form as filter C'' - until your patience runs out
 +
 
 +
 
 +
----
 +
 
 +
                             
 +
=== Example 8. All married males with family name containing rechter/richter ===
 +
 
 +
                                          '''''Person Filter Editor'''''
 +
'''''Filter A:'''''
 +
    Event filters=>
 +
          People with the family <event>: Family event=> Family:= Marriage
 +
    General filters=>
 +
          Males
 +
 
 +
'''All rules must apply'''
 +
 
 +
'''''<Run Filter A> in Person View''''' ''to check''
 +
 
 +
THEN in the '''Filter sidebar''', enter ''r[ei]chter'' in the '''Name''' field, for the '''Custom filter''' select ''Filter A'', check '''Use regular expressions'''. Click '''Find'''.
 +
 
 +
 
 +
 
 +
----
 +
 
 +
                             
 +
=== Example 9.  All descendants of Joan Doe of female or unknown sex ===
 +
 
 +
 
 +
                                          '''''Person Filter Editor'''''
 +
'''''Filter A:'''''
 +
    General filters=>
 +
          Males
 +
 
 +
 
 +
'''All rules must apply'''
 +
 
 +
'''**Return values that do *not* match the filter rules**'''
 +
 
 +
 
 +
'''''Filter B:'''''
 +
    Descendant filters=>
 +
          Descendants of person:=<here find the ID of Joan Doe>; Include original person
 +
 
 +
'''All rules must apply'''
 +
 
 +
'''THEN <Run Filter B> in Person View'''
 +
 
 +
 
 +
----
 +
 
 +
----
 +
 
 +
----
 +
 
 +
 
 +
=='''''3-stage FILTERS'''''==
 +
 
 +
 
 +
 
 +
 
 +
                             
 +
=== Example 1. All marriages where the event is a "Personal" event but not part of a Family ===
 +
 
 +
                                          '''''Person Filter Editor'''''
 +
'''''Filter A:'''''
 +
Event filters=>
 +
        People with the family <event>;  Family Event:="Marriage"
 +
 
 +
'''All rules must apply'''
 +
 
 +
'''**Return values that do *not* match the filter rules**'''
 +
 
 +
 
 +
'''''Filter B:'''''
 +
Event filters=>
 +
        People with the personal <event>; Personal Event:="Marriage"; Primary role:="1"
 +
 
 +
'''All rules must apply'''
 +
 
 +
 
 +
'''''Filter C:'''''
 +
  General filters=>
 +
        People matching the <filter>; Filter name:= "A"
 +
  General filters=>
 +
        People matching the <filter>; Filter name:= "B"
 +
 
 +
'''All rules must apply'''
 +
 
 +
 
 +
'''<Run Filter C> in Person View'''
 +
 
 +
 
 +
----
 +
 
 +
 
 +
                             
 +
=== Example 2. People with events with place, to show an ancestor's descendants with no known birthplace ===
 +
 
 +
                                          '''''Place Filter Editor'''''
 +
'''''Filter A:'''''
 +
Position filters=>
 +
        Places with no latitude or longitude given
 +
 
 +
'''All rules must apply'''
 +
 
 +
 
 +
                                          '''''Event Filter Editor'''''
 +
'''''Filter B:'''''
 +
  General filters=>
 +
        Events with the particular type:  Event type:="Birth"
 +
  General filters=>
 +
        Events of Places matching the <place filter>: Place filter name:=”A”
 +
 
 +
'''All rules must apply'''
 +
 
 +
 
 +
                                          '''''Person Filter Editor'''''
 +
'''''Filter C:'''''
 +
  Descendant filters=>
 +
        Descendant family members of <person>:= <''here select the particular ancestor ID''>
 +
  General filters=>
 +
        Persons with events matching the <event filter>: Event Filter name:=”B”
 +
 +
'''All rules must apply'''
 +
 
 +
 
 +
'''<run Filter C> in Person View'''
 +
 
 +
 
 +
 
 +
----
 +
 
 +
 
 +
 
 +
                             
 +
=== Example 3. All direct ancestors (and their siblings) of some person in set periods, e.g. 50 yrs ===
 +
 
 +
 
 +
''Comment: For example, to show when the migration from country to town took place''
 +
 
 +
                                          '''''Person Filter Editor'''''
 +
'''''Filter A:'''''
 +
    Descendant filters=>
 +
            Descendant family members of <person>; select the person's ID; Include the original person
 +
 
 +
'''All rules must apply'''
 +
 
 +
 
 +
                                          '''''Event Filter Editor'''''
 +
'''''Filter B:'''''
 +
  General filter =>
 +
        Events of persons matching the <person filter>: Person filter name:= "A"
 +
  General filter=>
 +
        Events with <data>: Event type:= "Birth"; Date:="between 1650 and 1750" ''(say)''
 +
 
 +
'''All rules must apply'''
 +
 
 +
 
 +
                                          '''''Place Filter Editor'''''
 +
'''''Filter C:'''''
 +
  General filters=>
 +
        Places of events matching the <event filter>: Event filter name:=  "B"
 +
 
 +
'''All rules must apply'''
 +
 
 +
 
 +
'''<run Filter C> in Place View'''
 +
 
 +
 
 +
 
 +
----
 +
 
 +
 
 +
                             
 +
=== Example 4. End of the line ancestors from a particular person X (Jones) ===
 +
 
 +
 
 +
''Deal with the father's and mother's side separately.''
 +
 
 +
'''[father's side]'''
 +
 
 +
                                          '''''Person Filter Editor'''''
 +
'''''Filter A:'''''
 +
    Family filters=>
 +
          People missing parents
 +
 
 +
'''All rules must apply'''
 +
 
 +
 
 +
'''''Filter B:'''''
 +
    Ancestral filters=>
 +
          Ancestors of <person>: ID := <''here find ID of person X''>
 +
    General filters=>
 +
          Males
 +
    General filters=>
 +
          People with the <name>:Full Family Name:="Jones"
 +
 
 +
'''All rules must apply'''
 +
 
 +
 
 +
'''''Filter C:'''''
 +
    General filters=> 
 +
          People matching the filter; Filter name:="A"
 +
    General filters=>
 +
          People matching the filter; Filter name:="B"
 +
 
 +
'''All rules must apply'''
 +
 
 +
 
 +
 
 +
'''<Run Filter C> in Person View.'''
 +
 
 +
'''[mother's side]'''
 +
 
 +
repeat A, B, C but in Filter B substitute the ID of the mother of X for the ID of X, and the family name of the mother of X for the name “Jones”.
 +
 
 +
''Comment: if the spelling of the surname has changed over the generations, you'll need to use a regular expression for the Full Family Name in Filter B and enable “Use regular expressions”''
 +
 
 +
 
 +
----
 +
 
 +
 
 +
 
 +
 
 +
=== Example 5. Show birthplaces of all people with the surname Whitesmith ===
 +
 
 +
                                          '''''Person Filter Editor'''''
 +
'''''Filter A:'''''
 +
 
 +
    General filters=>
 +
          People with the <name> : Full family name:="Whitesmith"
 +
         
 +
 
 +
'''All rules must apply'''
 +
 
 +
 
 +
                                          '''''Events Filter Editor'''''
 +
'''''Filter B:'''''
 +
 
 +
    General filters=>
 +
          Events of persons matching the <person filter>: Filter name:="A"
 +
    General filters=>
 +
          Events with the particular type: Event type:="Birth"
 +
         
 +
 
 +
'''All rules must apply'''
 +
 
 +
 
 +
                                          '''''Places Filter Editor'''''
 +
'''''Filter C:'''''
 +
 
 +
    General filters=>
 +
          Places of events matching the <event filter>: Event filter name:="B"
 +
         
 +
 
 +
'''All rules must apply'''
 +
 
 +
'''''<Run Filter C> in Place View''' to check''
 +
 
 +
 
 +
 
 +
 
 +
These Places can be displayed in '''Geography View'''
 +
 
 +
Select '''All Known Places''', but use '''Filter sidebar''' with '''Custom filter "C"''' to restrict the places shown to birthplaces of the Whitesmith family
 +
 
 +
 
 +
''[Acknowledgement: thanks to S. Noiraud for pointing out this very useful combination of filter and Geography View]
 +
''
 +
 
 +
 
 +
 
 +
 
 +
 
 +
----
 +
 
 +
----
 +
 
 +
----
 +
 
 +
== '''''5-stage FILTERS''''' ==
 +
 
 +
 
 +
                             
 +
=== Example 1. People with surname Doe who lived in Illinois State ===
 +
 
 +
                                          '''''Place Filter Editor'''''
 +
'''''Filter A:'''''
 +
    General filters=>
 +
          Places matching parameters: Name:= "Illinois"; Place type:= "State"
 +
 
 +
'''All rules must apply'''
  
  
==Introduction==
+
                                          '''''Event Filter Editor'''''
For more info, see [[Filter]].
+
'''''Filter B:'''''
To test the filters, make sure you have the Filter sidebar visible (you can select this in the View menu), and select the custom filter you made, before clicking on Find.
+
    General filters=>
 +
          Events of places matching the <place filter>: Place filter name:="A" 
  
Example: People with surname Doe and who lived in Illinois State:
+
'''All rules must apply'''
===Here is the Logic for it....===
 
If that filter excists, the logic would be:
 
1/make place filter1: state = Illinious
 
2/make event filter1 which is an or combination of three other event filters:
 
    (type=residence or type =death) and (events matching place filter1)
 
3/make person filters: persons satisfying event filter 1.
 
  
The extra filter is not that hard, the code is present in trunk (gramps 3.0) to easily add that
 
  
== Example: All female descendants of Joan Doe==
+
                                          '''''Person Filter Editor'''''
=== Simple implementation ===
+
'''''Filter C:'''''
The following does exactly what is asked:
+
    General filters=>
*In the Edit view, go to Joan Doe, and note the GRAMPS ID.
+
          People with events matching the <event filter>: event filter name:= "B"
*In the View menu, select ''Person Filter Editor''
+
    Event filters=>
*Click on ''Add a New Filter''. In the Define filter dialog, give the filter the name ''Female descendants of Joan Doe''
+
          People with the personal <event>: Personal event:="Residence"
*Next to the rule list, click on ''Add another rule to the filter'', which opens the ''Add Rule'' Dialog.
 
*Go to Descendant filters, and select the rule ''Descendants of <person>''. Give as value the GRAMPS ID, and select the box ''include original person''
 
*Click again on ''Add another rule'', and now go to ''General filters'', and select the rule ''females''
 
*In the options section of the Define filter dialog, make sure ''all rules must apply'', is selected
 
  
=== A variation: also return unknown sex ===
+
'''All rules must apply'''
You might want to add the people with unknown sex to the output. For this, you need to combine two filters:
 
*Make a filter: ''female or unknown'', consisting of one general filter: ''males'', and in the options you select: ''return values that do not satisfy the filter rules''
 
*Make a second filter: ''female or unknown descendants of Joan Doe'', with as rules ''Descendants of <person>'' where the value is the GRAMPS ID of Joand Doe, and as second rule the general filter ''People matching the <filter>'', with as value for <filter> ''female or unknown''
 
*Again, in the Define filter dialog, ''all rules must apply'' must be checked
 
  
=== Slightly different: only female line===
 
In this case, you only want to see the female line, so a female child of a male descendants of Joan Doe should '''not''' be present.
 
  
As far as I can tell, this is not possible in 2.2.6. You should do a feature request if you need this.
+
'''''Filter D:'''''
 +
    General filters=>
 +
          People with events matching the <event filter>: event filter name:= "B"
 +
    Event filters=>
 +
          People with the personal <event>: Personal event:="Death"
  
 +
'''All rules must apply'''
  
==Example: All married males with family name containing rechter/richter==
 
Three possibilities are given. Although one might be inclined to use one of the first two, the third filter, using the family object, is clearly the easiest, and most straightforward.
 
=== Use the Marriage event ===
 
* With Person Filter Editor, create a custom filter with name ''MarriageFamEventMale''. Add the rule 'People with Family <event>', event "Marriage". Next add the rule 'Males'
 
* In the Filter dialog, make sure the option 'all rules must apply' is checked.
 
* In the Filter sidebar, type in Name field: r<nowiki>[ei]</nowiki>chter, select Custom Filter: ''MarriageFamEventMale'', and check the box 'User regular expressions'. Click Find.
 
  
=== Allow for relationship Married ===
+
'''''Filter E:'''''
We adopt the previous filter, by also looking at relationship Married, even if no event marriage is present.
+
    General filters=>
* With Person Filter Editor, create a custom filter with name ''MarriedRelMale''. Add the rule ''People with the <relationships>'' to the filter, and select as value for relationship: Married. Next add the rule ''Males''. Make sure the option ''all rules must apply'' is checked
+
          People matching the <filter>: Filter name:= "C"
* With Person Filter Editor, create a custom filter, name ''MarriedMale''. Add the rule ''People matching the <filter>'' twice, once with filter ''MarriageFamEventMale'', once with filter ''MarriedRelMale''.
+
    General filters=>
* Make sure that for this filter, the option ''at least one rule must apply'' is selected
+
          People matching the <filter>: Filter name:= "D"
* In the Filter sidebar, type in Name field: r<nowiki>[ei]</nowiki>chter, set Gender: Male, Custom Filter: ''MarriedMale'', and check the box ''Use regular expressions''. Click Find.
 
  
=== Use a Family filter instead ===
 
Alternatively, one can find an answer to this query by looking in the Family list view at relationship Married, or event Marriage.
 
* With Family Filter Editor, create custom filter, name ''MarriedFamily''. Add the rule ''Families with the <event>'', and set event to "Marriage". Next add the rule ''Family with relationship type'', with value ''Married''.
 
* For the filter ''MarriedFamily'' select the option: ''at least one rule must apply''
 
* In the Family List view, go to the Filter Sidebar, and type for father name ''r<nowiki>[ei]</nowiki>chter'', select as custom filter ''MarriedFamily'', and select the ''Use regular expressions'' checkbox, and click find.
 
* Set the columns of the family view to only view the father (in the edit menu, select column editor).
 
* Optional: The name of the father can be added to the custom filter with the rule 'Families with father with the <name>', however, in that case the name of the custom filter is better changed to eg. ''MarriedRechterFamily'', and in the rules with <name> no regular expressions can be used, making it not usefull to find variants like ''richter'' at the same time
 
  
== Unconnected/unrelated people ==
+
'''**At least one rule must apply**'''
This is a filter to determine which people in your tree have no direct connection to you.
 
  
=== List all unconnected people===
 
*Create a new custom person filter using ''Edit->Person Filter Editor''.
 
*Add a rule to the new filter: ''General filters->Disconnected people''.
 
*Save the filter with a name
 
*In the People view, turn on the filter sidebar and apply the new filter.
 
  
The People view will now only display people who are not connected to any other people.
+
'''<Run Filter E> in Person View.'''
  
Note that only individually-disconnected people will be shown, not families.  (See the [[Unsupported Plugins#Not_Related|Not Related plugin]] to find both people and families that are disconnected.)
 
  
=== List all people not related to you ===
+
----
If you want people that are not related to you, do this:
 
  
*Create a new custom person filter using ''Edit->Person Filter Editor''.
 
*Add a rule to the new filter: ''Ancestral filters->People with a common ancestor with <person>''. (choose yourself as the person)
 
*Check the option marked ''Return values that do not match the filter rules''
 
*Save the filter with a name
 
In the People view, turn on the filter sidebar and apply the new filter.
 
*The People view will now only display people who are not related to you.
 
  
{{languages|Example filters}}
+
[[Category:Gramps Examples]]
 +
[[Category:Filters]]

Revision as of 19:35, 13 June 2020

A collection of examples of filters.

Introduction

For more info, see Filter and also the wiki manual on Filters. When creating custom filters, always make sure you have the Filter Gramplet in the sidebar visible. This allows testing the filter on real data before putting the filter in general use. Test each filter individually... don't set up a 2nd stage filter until the 1st stage has been tested. To test: in the Filter tab of the sidebar, select the custom filter you made; then click the Find button.

Create a custom filter with the following steps:

  • Click on Edit in the menu bar to display the drop-down list
The last item is the ____ Filter Editor and it is contextual, changing the filter editor to only show filters for the category of the current View
  • Click on the Filter Editor
  • Click on Filter Editor STOCK_ADD Add a new filter to start creating a new filter
  • Give your filter a unique name
  • Click on Define Filter : Rule List STOCK_ADD Add another rule to the filter to see the filter rules (limited to those available in the current View)
  • Select an appropriate filtering rule
  • Add further rules as needed
  • Select the appropriate Define Filter : Options pop-up menu item to define how the rules interact. The [[man menu|All rules must apply}} option is selected by default. This is only necessary when there are multiple rules.
  • Click on the Define Filter OK
  • Click on the Filter Editor Close Note that new custom filters (or changes) only take effect after closing the Filter Editor.


There are rules to allow you to use filters defined for another View. In this way you can build up complex filtering involving several Views.

Gnome-important.png
Custom Filters are resource hungry

Very large databases may encounter resource limitations when handling some complex filters


Most of the following examples appeared on the Gramps-Users mailing list in response to posts from users and cover Gramps versions 3.4.x to 4.1x



Construction of custom filter examples

      Please note these conventions for the construction of Filters:
                             <Viewname> Filter Editor.................Editor for this particular View

Filter <filtername>:...........................................................................................................Name of new filter

  <rule name> ........................................................Filter rule selected
  OR
  <rule group name> => 
       <selected rule name> ..........................................Filter rule selected from a drop-down group of rules

Option selected ................................................................................................................. All/At least one rule must be obeyed

Use regular expressions ................................................................................................. Blank if not required

<Run Filter <filtername> in <Viewname> View> .....................................................Where to run the new filter






1-stage FILTERS

Example 1. All sources that have no repository

                                          Source Filter Editor

Filter A:

General filters=> 
   Sources with <count> Repository references; Number of instances:="1"; Number must be:="lesser than"
OR
   Sources with a reference count of <count>; Reference count must be:= "lesser than"; Reference count:="1"

All rules must apply

<Run Filter A> in Source View




Example 2. All individuals with no name

Comment: In Person View, click on the Name column to get the names in alphabetical order. All blank surnames will be at the top of the list

                 The following filter will display only the blank given names and/or surnames
                                         Person Filter Editor

Filter A:

   General filters=>
         People with the <name>; Given Name:=^$; Full Family Name:=^$

Use regular expressions

All rules must apply

<Run Filter A> in Person View




Example 3. All female descendants of Joan Doe

                                          Person Filter Editor

Filter A:

Descendant filters=>
      Descendants of <person>: <here find the ID of Joan Doe> ; Include original person
General filters=>
      Females

All rules must apply

<Run Filter A> in Person View






2-stage FILTERS

Example 1. All people with only one parent recorded

                                          Person Filter Editor

Filter A:

   General filters=> 
         Persons with the <name>; Given name:="(^$|[uU]known)"; Full Family Name:="(^$|[uU]known)"

**Use regular expressions**

All rules must apply


Filter B:

   Family filters=>
         Children of <filter> match; Filter name:="B"

All rules must apply


THEN <Run Filter B> in Person View

Comment: If both parents are unknown you probably won't have any gramps ID assigned for them




Example 2. Individuals with siblings named “John”

                                          Person Filter Editor

Filter A:

   General filters=> 
         People with the <name>: Given Name:="John"

All rules must apply

Filter B:

   Family filter=> 
         Siblings of <filter> match: Filter name:="A”

All rules must apply


THEN <Run Filter B> in Person View




Example 3.“Timeline” of all people associated with a particular place

                                          Place Filter Editor

Filter A:

   General filters=>  
         Places matching the parameters ;Name : <here insert name of place>

All rules must apply

                                          Event Filter Editor

Filter B:

   General filters=>  
         Events matching the place filter: Place filter name:=”A”

All rules must apply


THEN <Run Filter B> in Events view

Configure the View to show columns for Type, Description, Date, Place. Order the items by Date to get a timeline.


OR Alternative 2:
                                           Event Filter Editor

Filter A:

   General filters=>  
         Events with data : Place:= <here insert placename>

Comment: if the Event type default is "Birth"., just delete it

All rules must apply


THEN <run Filter A> in Events View


For an ordered list of the people add the following filter:

                                           Person Filter Editor

Filter B:

   General filters=>   
         Persons with events matching the events filter: Events filter name:= "A".

All rules must apply


THEN <run Filter B> in Person View





Example 4. All marriage events on the ancestral tree dated after 1837 for a named individual

                                          Person Filter Editor

Filter A:

   Event filters=>
         People with the personal <event>; Personal event:= Marriage; Date:= after 1837
   Event filters=>
         People with the family <event>; Family event:= Marriage; Date:= after 1837 

**At least one rule applies**

Filter B:

   General filters=>   
         People with the name; <here insert name of individual>
   General filters=>
         People matching the <filter>; Filter name:=”A”.

All rules must apply


THEN <run Filter B> in Person View





Example 5. All persons called "serge" having some connection with London

                                          Event Filter Editor

Filter A:

   General filters=>
         Events with : Place:="London"

All rules must apply

                                          Person Filter Editor

Filter B:

   General filters=>
         Persons with events matching the <event filter>: Event filter name:= "A"
   People with the <name>: Given name:="serge"

All rules must apply


THEN <run Filter B> in Person View


Comment1: There is no way of going between people and places except by way of events they were involved in at those places

Comment2: What looks like a minor bug appears when Person filtering on names: a few extraneous individuals appear. They are spouses, included because their married name (or occasionally spouse) is recorded in the database as their Alternative Name





Example 6. Obtain a ‘focused’ descendant chart containing only a subset of the people

Select the subset by tagging manually in your direct ancestral line up from your living relative. Call the tag, say, LINE 1.

                                          Person Filter Editor

Filter A:

   General filters=>
         People with the <tag>; Tag:="LINE 1"

All rules must apply

Filter B:

   Family filters=>
         Children of <filter> match: Filter name:="A"
   Family filters=>
         Spouses of <filter> match: Filter name:="A"
   Family filters=>
         Siblings of <filter> match: Filter name:="A"

**At least one rule must apply**


THEN <run Filter B> in Person View to display the “focussed” tree

OR:

  Reports=> Graphs=> Relationship Graph=> Report Options=> Filter "B" to obtain a chart. Save as SVG for further manipulation

OR:

 Family Trees=> Export=> Forward=> select Gramps XML package=> Forward=> Person Filter. 
 Click the drop-down list and select filter B to save the filter results as another family tree. 
 Name and export that gpkg; then you can create a new family tree and import the gpkg back into it.





Example 7. All people related to me but not my wife

                                          Person Filter Editor

Filter A:

   Ancestral filters=>
         Ancestors of <person> ID:= <here find YOUR ID>; Inclusive:=0  i.e.note: don't include yourself

All rules must apply


Filter B:

   Descendant filters=>
         Descendant family members of <filter> match; Filter name:="Filter A"

All rules must apply


THEN <Run Filter B> in Person View

Comment: note the difference between the UP filter ("Ancestors") which is restrictive and the DOWN filter ("Descendant family members of filter) which is inclusive. The former keeps the line of relationship away from the wife; the latter brings in your own in-laws ("Matches people that are descendants or the spouse of anybody matched by the filter")

Comment 2: the filter falls down on people who are not strictly connected to you by marriage but only indirectly i.e. people who were married at some time to one of your in-laws, i.e.."in-laws of in-laws".

If you want to incorporate those links as well, add a further filter as follows:

Filter C:

   Descendant filters=>
       Descendant family members of <filter> match; Filter name:="Filter B"

**At least one rule must apply**


THEN <Run Filter C> in Person View

Comment 3: you can widen the reach of the links further by adding more filters in the same form as filter C - until your patience runs out




Example 8. All married males with family name containing rechter/richter

                                          Person Filter Editor

Filter A:

   Event filters=>
         People with the family <event>: Family event=> Family:= Marriage
   General filters=>
         Males

All rules must apply

<Run Filter A> in Person View to check

THEN in the Filter sidebar, enter r[ei]chter in the Name field, for the Custom filter select Filter A, check Use regular expressions. Click Find.




Example 9. All descendants of Joan Doe of female or unknown sex

                                          Person Filter Editor

Filter A:

   General filters=>
         Males


All rules must apply

**Return values that do *not* match the filter rules**


Filter B:

   Descendant filters=>
         Descendants of person:=<here find the ID of Joan Doe>; Include original person

All rules must apply

THEN <Run Filter B> in Person View






3-stage FILTERS

Example 1. All marriages where the event is a "Personal" event but not part of a Family

                                          Person Filter Editor

Filter A:

Event filters=> 
       People with the family <event>;  Family Event:="Marriage"

All rules must apply

**Return values that do *not* match the filter rules**


Filter B:

Event filters=> 
       People with the personal <event>; Personal Event:="Marriage"; Primary role:="1"

All rules must apply


Filter C:

 General filters=>
       People matching the <filter>; Filter name:= "A"
 General filters=>
       People matching the <filter>; Filter name:= "B"

All rules must apply


<Run Filter C> in Person View




Example 2. People with events with place, to show an ancestor's descendants with no known birthplace

                                          Place Filter Editor

Filter A:

Position filters=> 
       Places with no latitude or longitude given

All rules must apply


                                          Event Filter Editor

Filter B:

 General filters=>
        Events with the particular type:  Event type:="Birth"
 General filters=>
        Events of Places matching the <place filter>: Place filter name:=”A” 

All rules must apply


                                          Person Filter Editor

Filter C:

 Descendant filters=>
        Descendant family members of <person>:= <here select the particular ancestor ID> 
 General filters=> 
       Persons with events matching the <event filter>: Event Filter name:=”B”

All rules must apply


<run Filter C> in Person View





Example 3. All direct ancestors (and their siblings) of some person in set periods, e.g. 50 yrs

Comment: For example, to show when the migration from country to town took place

                                          Person Filter Editor

Filter A:

   Descendant filters=> 
           Descendant family members of <person>; select the person's ID; Include the original person

All rules must apply


                                          Event Filter Editor

Filter B:

  General filter => 
        Events of persons matching the <person filter>: Person filter name:= "A"
  General filter=>
        Events with : Event type:= "Birth"; Date:="between 1650 and 1750" (say)
All rules must apply


                                          Place Filter Editor

Filter C:

  General filters=>
        Places of events matching the <event filter>: Event filter name:=  "B"

All rules must apply


<run Filter C> in Place View




Example 4. End of the line ancestors from a particular person X (Jones)

Deal with the father's and mother's side separately.

[father's side]

                                          Person Filter Editor

Filter A:

   Family filters=>
         People missing parents

All rules must apply


Filter B:

   Ancestral filters=>
         Ancestors of <person>: ID := <here find ID of person X>
   General filters=> 
         Males
   General filters=>
         People with the <name>:Full Family Name:="Jones"

All rules must apply


Filter C:

   General filters=>  
         People matching the filter; Filter name:="A"
   General filters=>
         People matching the filter; Filter name:="B"

All rules must apply


<Run Filter C> in Person View.

[mother's side]

repeat A, B, C but in Filter B substitute the ID of the mother of X for the ID of X, and the family name of the mother of X for the name “Jones”.

Comment: if the spelling of the surname has changed over the generations, you'll need to use a regular expression for the Full Family Name in Filter B and enable “Use regular expressions”





Example 5. Show birthplaces of all people with the surname Whitesmith

                                          Person Filter Editor

Filter A:

    General filters=>
          People with the <name> : Full family name:="Whitesmith"
         

All rules must apply


                                          Events Filter Editor

Filter B:

    General filters=> 
          Events of persons matching the <person filter>: Filter name:="A" 
    General filters=> 
          Events with the particular type: Event type:="Birth"
         

All rules must apply


                                          Places Filter Editor

Filter C:

    General filters=>
          Places of events matching the <event filter>: Event filter name:="B"
         

All rules must apply

<Run Filter C> in Place View to check



These Places can be displayed in Geography View

Select All Known Places, but use Filter sidebar with Custom filter "C" to restrict the places shown to birthplaces of the Whitesmith family


[Acknowledgement: thanks to S. Noiraud for pointing out this very useful combination of filter and Geography View]






5-stage FILTERS

Example 1. People with surname Doe who lived in Illinois State

                                          Place Filter Editor

Filter A:

   General filters=>
         Places matching parameters: Name:= "Illinois"; Place type:= "State"

All rules must apply


                                          Event Filter Editor

Filter B:

   General filters=>
         Events of places matching the <place filter>: Place filter name:="A"   

All rules must apply


                                          Person Filter Editor

Filter C:

   General filters=>
         People with events matching the <event filter>: event filter name:= "B"
   Event filters=>
         People with the personal <event>: Personal event:="Residence"

All rules must apply


Filter D:

   General filters=>
         People with events matching the <event filter>: event filter name:= "B"
   Event filters=>
         People with the personal <event>: Personal event:="Death"

All rules must apply


Filter E:

   General filters=>
         People matching the <filter>: Filter name:= "C"
   General filters=>
         People matching the <filter>: Filter name:= "D"


**At least one rule must apply**


<Run Filter E> in Person View.