This is an old revision of the document!


Understanding Expressions

Introduction

Expressions are an advanced feature of Family Historian, and occur most commonly in:

See the Family Historian Help > Using Family Historian > Advanced Topics > Expressions and Contexts of Use.

Expressions

Expressions are composed from two technical features:

  • Data References that often appear enclosed within percentage signs, e.g. %INDI.BIRT%
  • Functions that begin with an = sign (except when used within another Function), e.g. =RecordId()

They also often involve Operators such as + - * / = < > and or etc. See the Family Historian Help > Using Family Historian > Advanced Topics > Understanding Functions > Operators.

If having trouble displaying all the text in fields such as Note or Text From Source, see Display long text such as Notes.

Examples

The technical details are explained in the cross-references given above, so this section is a compilation of Expressions that FHUG members have found useful. Remember that certain components are interchangeable. For example Individual Facts such as INDI.BIRT, INDI.BAPM, INDI.CENS, INDI.RETI, INDI.DEAT, and even just INDI or INDI.NAME can often be substituted for each other, but Family Facts such as INDI.FAMS>MARR or INDI.FAMS>DIV or CUR_FAMS>MARR are different.

Record Id

Expression Description
=RecordId( ) Record Id of current record, usually INDIvidual
=RecordId( %SOUR% ) Record Id of current SOURce record
=RecordId( %INDI.~SPOU>% ) Record Id of current Spouse Individual record
=RecordId( %INDI.FAMC>% ) Record Id of current Parents Family record

Related Forum postings:

Fact & Name Fields

Expression Description
=Exists( %INDI.RETI.DATE% ) True if 1st Retirement Event has a Date defined
=Exists( %INDI.BAPM.SOUR>% ) True if 1st Baptism Event has a Source Citation
=Exists( %INDI.CENS[year=1901]% ) True if any Census Event has a Date in 1901
=Exists( %FAM.MARR.PLAC% ) True if 1st Marriage Event has a Place defined
=Exists( %INDI.FAMS>MARR.PLAC% ) An alternative to the preceding example
=Exists( %INDI.FAMS[2]>MARR.PLAC% ) Similar alternative, but for a 2nd Marriage Event
=ExistsText( %INDI.~CHIL>%, Text( %INDI.~CHIL>% . " (" . LifeDates2(%INDI.~CHIL>%) . ")" ) ) Gives 1st Child's Name and bracketed Life Dates
=TextPart( %INDI.BIRT.PLAC%, 3, 1, STD ) Gives 3rd comma separated part of Birth Place
=TextPart( %INDI.DEAT.ADDR%, 2, 0, TIDY ) Gives 2nd and subsequent tidied parts of Death Address
=IsTrue( ( AgeAt( %INDI%, %INDI.DEAT.DATE% ) >= 1 ) and ( AgeAt( %INDI%, %INDI.DEAT.DATE% ) <= 5 ) ) True if died aged between 1 and 5 years (needs a Birth & Death Date)
=IsTrue( AgeAt( %INDI%, EstimatedDeathDate( %INDI%, MID, 2 ) ) < 21 ) True if died aged less than 21 years (needs a Birth & Death, Burial, or Cremation Date)
=IsTrue( %INDI.BIRT.DATE:XDATETYPE%="Date" and %INDI.BIRT.DATE:DAY%>0 ) True if simple exact Date with Day, Month & Year
=GetField( %INDI%, "%INDI.CENS[year=" . ["Year"] . "]%" ) Compose complex Data Reference with Query prompt
=FieldText( GetRecord(%FACT%), 'INDI.NAME:SURNAME' ) List Surname of owner of Fact in a Query
=FieldText( FactOwner(%FACT%,1,MALES_FIRST), 'INDI.NAME:SURNAME_FIRST ') List in Surname order with Surname first
=Field( FactOwner(%FACT%,1,MALES_FIRST), 'INDI.NAME:SURNAME_FIRST' ) List in Surname order with Surname last

Typically %INDI.XXXX…% above can be replaced by %FACT…% in Fact Queries.

Related Forum postings:

Source Citation Fields

Expression Description
=IsTrue( %INDI.CENS[year=1871].SOUR>_TYPE% = "Census" ) True if a Census Event in 1871 has 1st Source Citation with a Type of Census
=ContainsText( %INDI.BAPM.SOUR>TITL%, "Baptism", STD ) True if 1st Baptism Event has 1st Source Citation with its Title/Name containing Baptism (Note STD is default and thus optional)
=IsTrue( Exists( %INDI.FAMS>MARR.SOUR>% ) or Exists( %INDI.FAMS[2]>MARR.SOUR>% ) or Exists( %INDI.FAMS[3]>MARR.SOUR>% ) ) True if 1st or 2nd or 3rd Marriage Event has a Source Citation
=ContainsText( %CUR_FAMS>MARR.SOUR>TITL%, "Marriage" ) True if 1st Marriage Event has 1st Source Citation with Title/Name containing Marriage for use in Diagrams in FH V6
=IsTrue( ( %INDI.BIRT.SOUR>_TYPE% = "Birth" ) or ( %INDI.BIRT.SOUR[2]>_TYPE% = "Birth" ) ) True if 1st Birth Event has 1st or 2nd Source Citation with a Type of Birth
=IsTrue( ContainsText( %INDI.BAPM.SOUR>TITL%, "Baptism" ) or ContainsText( %INDI.BAPM.SOUR[2]>TITL%, "Baptism" ) or ContainsText( %INDI.BAPM.SOUR[3]>TITL%, "Baptism" ) ) True if 1st Baptism Event has 1st or 2nd or 3rd Source Citation with its Title/Name containing Baptism

Typically %INDI.XXXX…% above can be replaced by %FACT…% in Fact Queries.

Related Forum postings:

Relationships

Expression Description
=IsAncestorOf( %INDI%, FileRoot() ) True for all Ancestors of the File Root
=IsAncestorOf( %INDI%, Field( FileRoot(), 'INDI.~FATH>' ) ) True for paternal Ancestors of File Root
=IsAncestorOf( %INDI%, Field( FileRoot(), 'INDI.~MOTH>' ) ) True for maternal Ancestors of File Root
=Relationship( FileRoot(), %INDI% ) Textual relationship of Individual to File Root
=Relationship( %CUR_FILE_ROOT%, %INDI% ) Textual relationship of Individual to File Root in FH V6
=Relationship( FileRoot(), %FAM.HUSB>% ) Textual relationship of Husband of Family to File Root
%INDI.NAME:ADORNED_FULL% (=LifeDates2()) is =Relationship( FileRoot(), %INDI% ) of =FileRoot() Individual Summary Report > Report > Options > Format > Heading > Record with relationship of Individual to File Root
%INDI.NAME:ADORNED_FULL% (=LifeDates2())=TextIf( IsRelativeOf( FileRoot(), %INDI% ), Text( " is " . Relationship( FileRoot(), %INDI% ) . " of " . FileRoot() ), "" ) As above, but copes with an unrelated Individual
{default} are =Relationship( FileRoot(), %FAM.HUSB>% ) and =Relationship( FileRoot(), %FAM.WIFE>% ) of =FileRoot() Family Group Sheet > Report > Options > Format > Heading > Record with relationship of each Spouse to File Root

Related Forum postings:

Sentence Templates

These are found in Tools > Fact Types > Edit and affect Narrative Reports as discussed in Narrative Report Fact Sentence Templates.

The following are alternatives to the word married in the Marriage Event default Sentence Template :-

Expression Description
{=TextIf( %CUR_PRIN.SEX% = %CUR_PRIN2.SEX%, "entered a Civil Partnership with", "married" )} Same Sex Civil Partnership
{=CombineText( "entered a ", GetLabelledText( %FACT.NOTE2%, "Status: " ), " with", "married" )} Labelled Note Status: Ceremony

Related Forum postings:

Override Templates

These are found in Tools > Fact Types > Edit > Advanced and affect Fact displays in the Property Box Facts tab and the Records Window Individuals tab. These examples indicate the presence (*) or lack (-) of Sources and presence (+) or lack (-) of Media for each Fact. Note how using {abbr} {value} {place} adds the Place field to Attributes that do not include it by default.

Expression Description
{=TextIf( Exists(%FACT.SOUR>%),"*","-" )}{=TextIf( Exists(%FACT.SOUR>OBJE>%),"+"," -")} {abbr} {value} {place} Source & Media in Facts tab
{=TextIf( Exists(%FACT.SOUR>%),"*","-" )}{=TextIf( Exists(%FACT.SOUR>OBJE>%),"+"," -" )} {abbr} {date} {place} Similarly for Records Window
{=TextIf( Exists(%FACT.SOUR>%),"*","-" )}{=TextIf( Exists(%FACT.SOUR.OBJE>%),"+"," -" )} {abbr} {value} {place} Citation & Media in Facts tab

ƒh V6.1 can show a Media icon in the Facts tab More column if any Media are attached to the Fact, its Citations, or its Sources.

Related Forum postings: