Page 1 of 1
Parameter calculation in Query
Posted: 04 Jul 2020 10:58
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
Re: Parameter calculation in Query
Posted: 04 Jul 2020 11:16
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.
Re: Parameter calculation in Query
Posted: 04 Jul 2020 11:44
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

Re: Parameter calculation in Query
Posted: 04 Jul 2020 12:01
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.
Re: Parameter calculation in Query
Posted: 04 Jul 2020 12:22
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.
Re: Parameter calculation in Query
Posted: 04 Jul 2020 12:44
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.
Re: Parameter calculation in Query
Posted: 04 Jul 2020 13:10
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)