Page 1 of 1

Use expression to diplay icon in diagram

Posted: 23 Nov 2011 10:41
by johnmorrisoniom
I'm new to using expressions, although I have succeeded in modifying queries.
Thanks to Jane, I have succesfully added an expression to a diagram to display an icon that is pool number dependant.
I would now like to create an expression to diplay an icon to match age at death.
Say age at death <1, another for age at death between 1 & 5 and so on.
I keep getting invalid expression errors.
Help Please?

ID:5588

Use expression to diplay icon in diagram

Posted: 23 Nov 2011 12:17
by tatewise
This is much trickier than it first appears.
Firstly, age at death can be in various formats, such as Years, Months, Days, Younger than, Older than, Child, Infant, Stillborn.
So it is not a simple Number value, and also is not a Text field.

A partial solution that works assuming the Age is always recorded in Years is:
=Bool(TextToNumber(%INDI.DEAT.AGE%) < 99)

However, this gives erroneous results for all other formats.
To eliminate the Younger than, Older than, Child, Infant, Stillborn formats, which all return 0 from the TextToNumber(%INDI.DEAT.AGE%) function, you could use:
=Bool(Not(TextToNumber(%INDI.DEAT.AGE%) = 0) and (TextToNumber(%INDI.DEAT.AGE%) < 99))

But, any ages in Months or Days will still give erroneous results.
I have tried testing the %INDI.DEAT.AGE% field using functions such as ContainsText() but with no success.

Use expression to diplay icon in diagram

Posted: 24 Nov 2011 08:21
by Jane
Another option might be to use


=IsTrue(AgeAt(%INDI%,%INDI.DEAT.DATE%) < 60)

Use expression to diplay icon in diagram

Posted: 24 Nov 2011 09:27
by johnmorrisoniom
Thanks Jane,
But how can I specify and range such as older than 50 but under 60.
I have tried putting the expression in twice with and in between, but that isn't valid
=IsTrue(AgeAt(%INDI%,%INDI.DEAT.DATE%) 50)
I have Icons for different age bands, and up to now have been setting flags,.
If i can get this way to work then it is less work.

Use expression to diplay icon in diagram

Posted: 24 Nov 2011 12:13
by tatewise
You do not need the second IsTrue so try:
=IsTrue((AgeAt(%INDI%,%INDI.DEAT.DATE%) 50))

Use expression to diplay icon in diagram

Posted: 24 Nov 2011 12:20
by johnmorrisoniom
Thanks Jane.
That works a treat.
It ignores what is entered in the field and works off the internally calculated value, so text to number conversion is not needed