* Parameter calculation in Query

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
quarlton
Famous
Posts: 166
Joined: 26 Feb 2004 13:07
Family Historian: V7
Location: Lincolnshire
Contact:

Parameter calculation in Query

Post by quarlton »

Is it possible to calculate a value from a parameter in a Query?


Note: This is an example to explain the principle of what I am trying to achieve, not a specific query.

Prompt for a year of birth

Code: Select all

Add if %INDI.BIRT[1].DATE:YEAR%  was later than
... with a parameter of BirthYear

Upon running, the value of 1900 is entered for the parameter 'BirthYear'
This will return all people with a birth year after 1900

What I would now like to do is reference the parameter 'BirthYear' and calculate another year based on it.

Code: Select all

Exclude if %INDI.DEAT[1].DATE:YEAR% was earlier than BirthYear+50
This would exclude all those who died aged under 50

Many thanks
Dave Simpson ~ Boulton, Braham, Carney, Simpson and Jacobs
User avatar
LornaCraig
Megastar
Posts: 3201
Joined: 11 Jan 2005 17:36
Family Historian: V7
Location: Oxfordshire, UK

Re: Parameter calculation in Query

Post by LornaCraig »

I don't think you can caluclate a value from a parameter, but I am ready to be corrected.

In the example you have given (which I know is not the specific query you want) you could simply exclude anyone whose 'age at death' was under 50. See the standard query Age at Death for the expression to use. So there may always be other ways to achieve the outcome you want.
Lorna
avatar
quarlton
Famous
Posts: 166
Joined: 26 Feb 2004 13:07
Family Historian: V7
Location: Lincolnshire
Contact:

Re: Parameter calculation in Query

Post by quarlton »

Hi Lorna

Thanks, I thought that might be the case.

Unfortunately it is the built-in functions such as AgeAt that I am trying to circumvent :)
Dave Simpson ~ Boulton, Braham, Carney, Simpson and Jacobs
User avatar
tatewise
Megastar
Posts: 28414
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Parameter calculation in Query

Post by tatewise »

Yes, you can do that but involves a =Calc(...) function in the Expression:
Condition: Exclude if
Expression: =Calc( ( %INDI.DEAT[1].DATE:YEAR% - ["Year"] ) + 50 )
Operator: is less than
Value: 0

As Lorna says, there are other possibilities and considerations to take into account.

BTW: Your logic is slightly wrong in your example. That does not test for people who died before they were aged 50. It tests for anyone who died earlier than 1950 regardless of age.

The aged less than 50 filter would be:
Condition: Exclude if
Expression: =Calc( %INDI.DEAT.DATE:YEAR% - %INDI.BIRT.DATE:YEAR% )
Operator: is less than
Value: 50

But all the above only work rationally if there are Dates for both Birth and Death events.

It might help if you explain what problem you are trying to solve rather than your attempted solution.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
avatar
quarlton
Famous
Posts: 166
Joined: 26 Feb 2004 13:07
Family Historian: V7
Location: Lincolnshire
Contact:

Re: Parameter calculation in Query

Post by quarlton »

Thanks Mike that's exactly what I'm looking for.

I'm not really trying to do anything in particular, I simply wanted to find out if it were possible, and my example was simply that.
Dave Simpson ~ Boulton, Braham, Carney, Simpson and Jacobs
User avatar
tatewise
Megastar
Posts: 28414
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Re: Parameter calculation in Query

Post by tatewise »

You can use various arithmetic and conditional operators in conjunction with =Calc, =Diff, =IsTrue, etc, functions.

Check the FH Help page on Operators that has lots of examples and advice about use in Query Expressions.

Just remember to substitute the ["Label"] parameter value where needed, and may need one of the Type-Specifier wrapper functions: =Text, =Number, =Item, =Indiviudal, =Date, =Bool.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry
User avatar
Jane
Site Admin
Posts: 8514
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Re: Parameter calculation in Query

Post by Jane »

The page Mike recommended can be viewed at
https://www.family-historian.co.uk/help ... ators.html

If you can't find it in the Help (it's in Using Family Historian>Advanced)
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."
Post Reply