How to create a Cousin Report

In my legacy application I have a report that shows all cousins (and siblings) for a source person. Beside the blood related persons also their (marriage) partners are found optionally. Additionally, a restriction according to living persons is possible.
The report outputs names, birth and death dates as well as (optionally) the ID.
(How) is something like this realizable in Gramps?

1 Like

There is no cousin report available as far as I know. The closest is probably the kinship report, but this report lists all related persons and not only siblings, cousins and partners.

You could create a multi-step custom filter and export the filtered person view as CSV if you need a list of only siblings, cousins and partners.

You have to do it with a double filter:

Step1: create a filter with the generation whose descendants you want

  • Ancestors of person not more than N generations away
  • Ancestors of person at least N generations away

Step2: Create a filter with their Descendants:

  • Descendant family members of filter match (here you put as value the name of the filter in step1

Hi Markus,
Thanks for your tips, I am only very short time with Gramps trying out.

I actually needed a triple filter:

  1. First select the grandparents of the source person.
  2. The result set as input for the grandparents’ children.
  3. And the second partial result as input for their children.

Unfortunately, the whole thing is very statically related to the person stored in the filter and I could not find a filter for ‘only living persons’ either. The ‘alive’ option in the export dialog just works the wrong way around for this case.

I suppose the solution could be a plugin and I am familiar with the programming, but I don’t have any direct Python experience. But it doesn’t look much different than SQL and VB…

Do you have a tip, what existing *.py I could take as a template?
And what is necessary around it to bring a new plugin to run (first only locally on the PC)?

There is the Active Person filter rule. It is an addon rule and is not installed with the core Gramps code.

First create a filter Active Person using the Active Person rule.
Instead of looking for the Grandparents of a set person, set it to Ancestors of <filter> match.

The problem with this rule, it only works from within the People/Grouped People list views. It does not work as a filter for reports/etc.

There is the People Probably Alive rule where you set a date. This rule will use the Maximum age probably alive: setting in Preferences.

Combine this rule with your final cousin filter with the option “All Rules must apply” option.

  1. Instead of active person filter, you can add a Bookmarked people filter. :arrow_right: person you are looking for cousins
  2. Add a Parents of <filter> match filter #1 :arrow_right: its parents
  3. Add a Parents of <filter> match filter #2 :arrow_right: its grand-parents
  4. Add a Children of <filter> match filter #3 :arrow_right: its aunts and uncles (and parents)
  5. Add a Children of <filter> match filter #4 :arrow_right: its cousins (and him or herself, and siblings)

Bookmark the person you want to obtain the cousins report (remove any other bookmarked persons)

Run the filter #5 or select it to run the report you want.

If you don’t want the person and its siblings, you have to create two more filters:

  1. A two rules filter:
  2. And another two rules filter:

Run filter #7

(I hope I didn’t make a mistake, I did that on my mind)

In addition to the Active Person filter and the Book Marked people filter, there is also a Home Person filter rule.

Sure but I generally don’t change my home person (me) so I prefer using bookmarks

This 7-step selection works as described, thanks for the help.

But I didn’t find a report (with such a simple layout as in the kindship report) that can be run with a filter as input.

Yes, the kinship report has exactly the data and the form I would see in the cousin report. And as you correctly pointed out, much, much more…

The ideal solution would be a clone of the report from which everything else is deleted. But that will probably not be so easy.

And what I also noticed: The report is created very quickly, while the multi-level filter solutions take much longer.

Another method

  1. Create a Tag called “FilterPerson
  2. Create a custom filter to locate the tagged person or people:
    TaggedFilterPerson” with the rule: “People with the <tag>” where the filter = “FilterPerson
  3. Create a full set of immediate relations custom filter rules:
    a) “Parents” with the rule: “Parents of <filter> match” where the filter = “TaggedFilterPerson”
    b) “Piblings” (Aunts and Uncles) with the rule: “Siblings of <filter> match” where the filter = “Parents”
    c) “1st cousins” with the rule: “Children of <filter> match” where the filter = “Piblings”
    d) “Siblings” with the rule: “Siblings of <filter> match” where the filter = “TaggedFilterPerson”
    e) “Niblings” (nieces and nephews) with the rule:: “Children of <filter> match” where the filter = “Siblings”

So all you have to do is apply a “FilterPerson” to one person or a set of People and run the appropriate Filter Rule. (You might want to add Spouses at some levels. But be careful of how that might unintentionally include blended family step-children as Cousins or Niblings.)

Hint: If you’re going to do a bunch of manipulations on the same set of relatives, Use the Add/Remove Tag tool Addon Tool to set Tags for that group of people. (You need to create the Tag BEFORE running the tool.) Then use the Filter gramplet’s tag filter instead of the Custom Filter. It reduces the filtering down to one pass.

I prefer to use tags to filter out exceptions: to filter out objects that I don’t want the filters to pop up.

For example in this case of cousins, if I didn’t want a cousin who was adopted (this is an example, I don’t see why I would do that), I would tag this person and filter this tag so as not to not take it into account in the results.

Adding and removing tags can be quite time consuming, so now I prefer to use them for exceptions

Not to hijack the thread, but this reminded me: what does the tick box “include Cousins”
in the options of the Kinship report supposed to do? Doesn’t work for me, the output is identical ticked or not- no cousins show up but they are in the DB.

I reserve 1 tag for Filter targeting.

Adding a Tag via a filter in the Add/Remove Tags tool seems to be a little faster than filtering in a View.

And Using the “Edit → Tag → Organize Tags…” for deleting and recreating that Tag is far quicker than using the tool.

Be aware that the Siblings filter rule doesn’t include half-siblings. See this feature request.

Using this tool takes so long, I use it only when I really need it

Is there a more efficient way to write custom filters to find cousins? The one below uses the “Home Person” as the foundation to find 1st cousins of the Home Person. It is awkward but works.

The most awkward part is the ancestor section. The Grandparents custom filter finds all the ancestors a certain number of generations away and subtracts the ancestors one generation nearer.

The Pedigree Gramplet compiles a list of Generations. (The lists default to ahnentafel number order.) The Pedigree generates lists of ancestor generations a lot faster than the custom filter.

But even though slow, the process cannot be extended to select a set of Nth cousins. The rule set lacks the necessary “Descendants of <filter> not more than <N> generations away” rule.

<?xml version="1.0" encoding="UTF-8"?>
<filters>
   <object type="Person">
      <filter name="Grandparents" function="one" comment="of Home Person">
         <rule class="IsLessThanNthGenerationAncestorOfDefaultPerson" use_regex="False">
            <arg value="3" />
         </rule>
         <rule class="IsLessThanNthGenerationAncestorOfDefaultPerson" use_regex="False">
            <arg value="2" />
         </rule>
      </filter>
      <filter name="Piblings" function="and" comment="of Home Person">
         <rule class="IsChildOfFilterMatch" use_regex="False">
            <arg value="Grandparents" />
         </rule>
      </filter>
      <filter name="Cousins" function="and" comment="of Home Person">
         <rule class="IsChildOfFilterMatch" use_regex="False">
            <arg value="Piblings" />
         </rule>
      </filter>
   </object>
</filters>

Here are the filters I use to find cousins of bookmarked people. It’s a lot of filters, but all you have to do is copy and paste if you want them.

Be aware that the IsSiblingOfFilterMatch rule includes only children of the “main parents” of a person. (See feature request 12443.)

<filter name="Bookmarked people" function="and">
  <rule class="IsBookmarked" use_regex="False">
  </rule>
</filter>
<filter name="Cousins of bookmarked people" function="or">
  <rule class="MatchesFilter" use_regex="False">
    <arg value="First cousins of bookmarked people"/>
  </rule>
  <rule class="MatchesFilter" use_regex="False">
    <arg value="First cousins once removed (down) of bookmarked people"/>
  </rule>
  <rule class="MatchesFilter" use_regex="False">
    <arg value="First cousins once removed (up) of bookmarked people"/>
  </rule>
  <rule class="MatchesFilter" use_regex="False">
    <arg value="First cousins thrice removed (down) of bookmarked people"/>
  </rule>
  <rule class="MatchesFilter" use_regex="False">
    <arg value="First cousins thrice removed (up) of bookmarked people"/>
  </rule>
  <rule class="MatchesFilter" use_regex="False">
    <arg value="First cousins twice removed (down) of bookmarked people"/>
  </rule>
  <rule class="MatchesFilter" use_regex="False">
    <arg value="First cousins twice removed (up) of bookmarked people"/>
  </rule>
  <rule class="MatchesFilter" use_regex="False">
    <arg value="Second cousins of bookmarked people"/>
  </rule>
  <rule class="MatchesFilter" use_regex="False">
    <arg value="Second cousins once removed (down) of bookmarked people"/>
  </rule>
  <rule class="MatchesFilter" use_regex="False">
    <arg value="Second cousins once removed (up) of bookmarked people"/>
  </rule>
  <rule class="MatchesFilter" use_regex="False">
    <arg value="Second cousins thrice removed (down) of bookmarked people"/>
  </rule>
  <rule class="MatchesFilter" use_regex="False">
    <arg value="Second cousins twice removed (down) of bookmarked people"/>
  </rule>
  <rule class="MatchesFilter" use_regex="False">
    <arg value="Second cousins twice removed (up) of bookmarked people"/>
  </rule>
  <rule class="MatchesFilter" use_regex="False">
    <arg value="Third cousins of bookmarked people"/>
  </rule>
  <rule class="MatchesFilter" use_regex="False">
    <arg value="Third cousins once removed (down) of bookmarked people"/>
  </rule>
  <rule class="MatchesFilter" use_regex="False">
    <arg value="Third cousins once removed (up) of bookmarked people"/>
  </rule>
  <rule class="MatchesFilter" use_regex="False">
    <arg value="Third cousins thrice removed (down) of bookmarked people"/>
  </rule>
  <rule class="MatchesFilter" use_regex="False">
    <arg value="Third cousins twice removed (down) of bookmarked people"/>
  </rule>
</filter>
<filter name="First cousins of bookmarked people" function="and" comment="children of aunts and uncles">
  <rule class="IsChildOfFilterMatch" use_regex="False">
    <arg value="Aunts and uncles of bookmarked people"/>
  </rule>
</filter>
<filter name="First cousins once removed (down) of bookmarked people" function="and" comment="children of first cousins">
  <rule class="IsChildOfFilterMatch" use_regex="False">
    <arg value="First cousins of bookmarked people"/>
  </rule>
</filter>
<filter name="First cousins once removed (up) of bookmarked people" function="and" comment="children of great-aunts and great-uncles">
  <rule class="IsChildOfFilterMatch" use_regex="False">
    <arg value="Great-aunts and great-uncles of bookmarked people"/>
  </rule>
</filter>
<filter name="First cousins thrice removed (down) of bookmarked people" function="and" comment="children of first cousins twice removed (down)">
  <rule class="IsChildOfFilterMatch" use_regex="False">
    <arg value="First cousins twice removed (down) of bookmarked people"/>
  </rule>
</filter>
<filter name="First cousins thrice removed (up) of bookmarked people" function="and" comment="children of great-great-great-aunts and great-great-great-uncles">
  <rule class="IsChildOfFilterMatch" use_regex="False">
    <arg value="Great-great-great-aunts and great-great-great-uncles of bookmarked people"/>
  </rule>
</filter>
<filter name="First cousins twice removed (down) of bookmarked people" function="and" comment="children of first cousins once removed (down)">
  <rule class="IsChildOfFilterMatch" use_regex="False">
    <arg value="First cousins once removed (down) of bookmarked people"/>
  </rule>
</filter>
<filter name="First cousins twice removed (up) of bookmarked people" function="and" comment="children of great-great-aunts and great-great-uncles">
  <rule class="IsChildOfFilterMatch" use_regex="False">
    <arg value="Great-great-aunts and great-great-uncles of bookmarked people"/>
  </rule>
</filter>
<filter name="fourth cousins of bookmarked people" function="and" comment="children of third cousins once removed (up)">
  <rule class="IsChildOfFilterMatch" use_regex="False">
    <arg value="Third cousins once removed (up) of bookmarked people"/>
  </rule>
</filter>
<filter name="Grandparents of bookmarked people" function="and" comment="parents of parents">
  <rule class="IsParentOfFilterMatch" use_regex="False">
    <arg value="Parents of bookmarked people"/>
  </rule>
</filter>
<filter name="Great-aunts and great-uncles of bookmarked people" function="and" comment="siblings of grandparents">
  <rule class="IsSiblingOfFilterMatch" use_regex="False">
    <arg value="Grandparents of bookmarked people"/>
  </rule>
</filter>
<filter name="Great-grandparents of bookmarked people" function="and" comment="parents of grandparents">
  <rule class="IsParentOfFilterMatch" use_regex="False">
    <arg value="Grandparents of bookmarked people"/>
  </rule>
</filter>
<filter name="Great-great-aunts and great-great-uncles of bookmarked people" function="and" comment="siblings of great-grandparents">
  <rule class="IsSiblingOfFilterMatch" use_regex="False">
    <arg value="Great-grandparents of bookmarked people"/>
  </rule>
</filter>
<filter name="Great-great-grandparents of bookmarked people" function="and" comment="parents of great-grandparents">
  <rule class="IsParentOfFilterMatch" use_regex="False">
    <arg value="Great-grandparents of bookmarked people"/>
  </rule>
</filter>
<filter name="Great-great-great-aunts and great-great-great-uncles of bookmarked people" function="and" comment="siblings of great-great-grandparents">
  <rule class="IsSiblingOfFilterMatch" use_regex="False">
    <arg value="Great-great-grandparents of bookmarked people"/>
  </rule>
</filter>
<filter name="Second cousins of bookmarked people" function="and" comment="children of parents' cousins">
  <rule class="IsChildOfFilterMatch" use_regex="False">
    <arg value="First cousins once removed (up) of bookmarked people"/>
  </rule>
</filter>
<filter name="Second cousins once removed (down) of bookmarked people" function="and" comment="children of second cousins">
  <rule class="IsChildOfFilterMatch" use_regex="False">
    <arg value="Second cousins of bookmarked people"/>
  </rule>
</filter>
<filter name="Second cousins once removed (up) of bookmarked people" function="and" comment="children of first cousins twice removed (up)">
  <rule class="IsChildOfFilterMatch" use_regex="False">
    <arg value="First cousins twice removed (up) of bookmarked people"/>
  </rule>
</filter>
<filter name="Second cousins thrice removed (down) of bookmarked people" function="and" comment="children second cousins twice removed (down)">
  <rule class="IsChildOfFilterMatch" use_regex="False">
    <arg value="Second cousins twice removed (down) of bookmarked people"/>
  </rule>
</filter>
<filter name="Second cousins twice removed (down) of bookmarked people" function="and" comment="children of second cousins once removed (down)">
  <rule class="IsChildOfFilterMatch" use_regex="False">
    <arg value="Second cousins once removed (down) of bookmarked people"/>
  </rule>
</filter>
<filter name="Second cousins twice removed (up) of bookmarked people" function="and" comment="children of first cousins thrice removed (up)">
  <rule class="IsChildOfFilterMatch" use_regex="False">
    <arg value="First cousins thrice removed (up) of bookmarked people"/>
  </rule>
</filter>
<filter name="Siblings of active person" function="and">
  <rule class="IsSiblingOfFilterMatch" use_regex="False">
    <arg value="Active person"/>
  </rule>
</filter>
<filter name="Siblings of my direct ancestors" function="and">
  <rule class="IsSiblingOfFilterMatch" use_regex="False">
    <arg value="My direct ancestors"/>
  </rule>
</filter>
<filter name="Third cousins of bookmarked people" function="and" comment="children of second cousins once removed (up)">
  <rule class="IsChildOfFilterMatch" use_regex="False">
    <arg value="Second cousins once removed (up) of bookmarked people"/>
  </rule>
</filter>
<filter name="Third cousins once removed (down) of bookmarked people" function="and" comment="children of third cousins">
  <rule class="IsChildOfFilterMatch" use_regex="False">
    <arg value="Third cousins of bookmarked people"/>
  </rule>
</filter>
<filter name="Third cousins once removed (up) of bookmarked people" function="and" comment="children of second cousins twice removed (up)">
  <rule class="IsChildOfFilterMatch" use_regex="False">
    <arg value="Second cousins twice removed (up) of bookmarked people"/>
  </rule>
</filter>
<filter name="Third cousins thrice removed (down) of bookmarked people" function="and" comment="children of third cousins twice removed (down)">
  <rule class="IsChildOfFilterMatch" use_regex="False">
    <arg value="Third cousins twice removed (down) of bookmarked people"/>
  </rule>
</filter>
<filter name="Third cousins twice removed (down) of bookmarked people" function="and" comment="children of third cousins once removed (down)">
  <rule class="IsChildOfFilterMatch" use_regex="False">
    <arg value="Third cousins once removed (down) of bookmarked people"/>
  </rule>
</filter>
1 Like

Thanks for this filter ‘emyoulation’!
However, I’m still not fit in using Gramps properly…
Where and how do I have to create and use this xml file? (Where) is there a step by step guide in the help?

Thanks for this filter George.
However, I’m still not fit in using Gramps properly…
Where and how do I have to create and use this xml file? (Where) is there a step by step guide in the help?