* Use expression to diplay icon in diagram

Older V4 Queries please post for any version in the General Forum
Locked
User avatar
johnmorrisoniom
Megastar
Posts: 882
Joined: 18 Dec 2008 07:40
Family Historian: V7
Location: Isle of Man

Use expression to diplay icon in diagram

Post by johnmorrisoniom » 23 Nov 2011 10:41

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

User avatar
tatewise
Megastar
Posts: 27082
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Use expression to diplay icon in diagram

Post by tatewise » 23 Nov 2011 12:17

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.
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
Jane
Site Admin
Posts: 8441
Joined: 01 Nov 2002 15:00
Family Historian: V7
Location: Somerset, England
Contact:

Use expression to diplay icon in diagram

Post by Jane » 24 Nov 2011 08:21

Another option might be to use


=IsTrue(AgeAt(%INDI%,%INDI.DEAT.DATE%) < 60)
Jane
My Family History : My Photography "Knowledge is knowing that a tomato is a fruit. Wisdom is not putting it in a fruit salad."

User avatar
johnmorrisoniom
Megastar
Posts: 882
Joined: 18 Dec 2008 07:40
Family Historian: V7
Location: Isle of Man

Use expression to diplay icon in diagram

Post by johnmorrisoniom » 24 Nov 2011 09:27

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.

User avatar
tatewise
Megastar
Posts: 27082
Joined: 25 May 2010 11:00
Family Historian: V7
Location: Torbay, Devon, UK
Contact:

Use expression to diplay icon in diagram

Post by tatewise » 24 Nov 2011 12:13

You do not need the second IsTrue so try:
=IsTrue((AgeAt(%INDI%,%INDI.DEAT.DATE%) 50))
Mike Tate ~ researching the Tate and Scott family history ~ tatewise ancestry

User avatar
johnmorrisoniom
Megastar
Posts: 882
Joined: 18 Dec 2008 07:40
Family Historian: V7
Location: Isle of Man

Use expression to diplay icon in diagram

Post by johnmorrisoniom » 24 Nov 2011 12:20

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

Locked