Counting Number of Same Events


Brian Horridge
 

Does anyone know if it's possible to return how many of a specific event an individuals has recorded for them

Specifically, I have been recording where individuals have been registered for voting (using the %INDI.EVEN-REGISTER_OF_ELECTORS[1].xxx%)  and some people have been at several different addresses.  I'm wondering if I can add a column to a query which gives a simple count of how many such events there are for each individual.

I've been using this "event" for a long time so I'm not sure now if this is a "standard" FH event or if it's one I created myself (as a custom event with date, place and address fields).

I suppose if it's possible, it could be used to count other multiple events such as census etc.

Many thanks

Brian


Mike Tate
 

Brian,

It is a custom event because its tag name starts with EVEN- and a custom attribute starts with _ATTR-

Standard facts all have a unique tag name such as BIRT, DEAT, MARR, CENS & OCCU

 

Yes, you can count the number but it is a bit awkward in a Query (it is easier in a Plugin but you must learn the language).

The expression needed is shown below to cater for up to 3 instances of the fact.

It works by testing if instance [3] exists and returns 3, or if instance [2] exists returns 2, or if instance [1] exists returns 1, else returns 0.

 

=NumberIf( Exists(%INDI.OCCU[3]%), 3, NumberIf( Exists(%INDI.OCCU[2]%), 2, NumberIf( Exists(%INDI.OCCU%), 1, 0 ) ) )

 

That strategy can be extended to cater for more instances. Just ensure you get the ( parentheses ) nested correctly.

 

Mike Tate

 


Brian Horridge
 

Mike

Thanks for that.  I kept extending the expression as I found some with more than 3.  Now I'm counting up to the 6th instance (max so far is 5 instances).

Again, thanks

Brian

On 27/03/2021 16:47, Mike Tate wrote:

Brian,

It is a custom event because its tag name starts with EVEN- and a custom attribute starts with _ATTR-

Standard facts all have a unique tag name such as BIRT, DEAT, MARR, CENS & OCCU

 

Yes, you can count the number but it is a bit awkward in a Query (it is easier in a Plugin but you must learn the language).

The expression needed is shown below to cater for up to 3 instances of the fact.

It works by testing if instance [3] exists and returns 3, or if instance [2] exists returns 2, or if instance [1] exists returns 1, else returns 0.

 

=NumberIf( Exists(%INDI.OCCU[3]%), 3, NumberIf( Exists(%INDI.OCCU[2]%), 2, NumberIf( Exists(%INDI.OCCU%), 1, 0 ) ) )

 

That strategy can be extended to cater for more instances. Just ensure you get the ( parentheses ) nested correctly.

 

Mike Tate

 


Virus-free. www.avg.com