Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
how_to:understanding_expressions [2018/02/23 09:13]
jane exchange FH code
how_to:understanding_expressions [2019/01/15 00:00]
Line 1: Line 1:
-====== Understanding Expressions ====== 
- 
-===== Introduction ===== 
- 
-**Expressions** are an advanced feature of Family Historian, and occur most commonly in: 
-  * **[[:​Glossary:​Queries]]** to specify Columns, Row filters, and Titles 
-  * **Diagram Text Schemes** to define the content of Diagram Boxes 
-  * [[.Using Flags and Icons and Expressions|Diagram > Options > Boxes > Conditions]] to define box style since {{fh}} V4 
-  * [[.Report Options:​Main Contents|Reports]] to define Data items in certain Report Sections 
-  * [[.Customising Record Window Columns]] or **Named List** Columns 
-  * **Captions** and **Custom Fields** in Property Boxes 
-  * **Sentence Templates** for **Narrative Reports** since {{fh}} V6 
-  * **Override Templates** for **Fact** displays since {{fh}} V6 
-See the **Family Historian Help > Using Family Historian > Advanced Topics > Expressions and Contexts of Use**. 
- 
-===== Expressions ===== 
- 
-**Expressions** are composed from two technical features: 
-  * **[[Understanding Data References|Data References]]** that often appear enclosed within percentage signs, e.g. **%INDI.BIRT%** 
-  * **[[Understanding Functions|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 Like 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: 
-  * [[topic>​t=12597|Generate a custom name list]] May 2015 
- 
-==== Fact & Name Fields ==== 
- 
-^ Expression ​                               ^ Description ​  ^ 
-| =Exists( %INDI.RETI.DATE% )               | True if 1<​sup>​st</​sup>​ **Retirement Event** has a **Date** defined ​      | 
-| =Exists( %INDI.BAPM.SOUR>​% )              | True if 1<​sup>​st</​sup>​ **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 1<​sup>​st</​sup>​ **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 2<​sup>​nd</​sup>​ **Marriage Event** ​        | 
-| =ExistsText( %INDI.~CHIL>​%,​ Text( %INDI.~CHIL>​% . " (" . LifeDates2(%INDI.~CHIL>​%) . "​)"​ ) )  | Gives 1<​sup>​st</​sup>​ **Child**'​s **Name** and bracketed **Life Dates** ​ | 
-| =TextPart( %INDI.BIRT.PLAC%,​ 3, 1, STD )  | Gives 3<​sup>​rd</​sup>​ comma separated part of **Birth Place** ​            | 
-| =TextPart( %INDI.DEAT.ADDR%,​ 2, 0, TIDY ) | Gives 2<​sup>​nd</​sup>​ 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: 
-  * [[topic>​t=12570|Using expressions]] May 2015 
-  * [[topic>​t=12543|burials and cremations]] April 2015 
-  * [[topic>​t=12487|Customizing Reports]] April 2015 
- 
-==== Source Citation Fields ==== 
- 
-^ Expression ​                                              ^ Description ​    ^ 
-| =IsTrue( %INDI.CENS[year=1871].SOUR>​_TYPE% = "​Census"​ )  | True if a **Census Event** in **1871** has 1<​sup>​st</​sup>​ **Source Citation** with a **Type** of **Census** ​  | 
-| =ContainsText( %INDI.BAPM.SOUR>​TITL%,​ "​Baptism",​ STD )  | True if 1<​sup>​st</​sup>​ **Baptism Event** has 1<​sup>​st</​sup>​ **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 1<​sup>​st</​sup>​ or 2<​sup>​nd</​sup>​ or 3<​sup>​rd</​sup>​ **Marriage Event** has a **Source Citation** ​  | 
-| =ContainsText( %CUR_FAMS>​MARR.SOUR>​TITL%,​ "​Marriage"​ )  | True if 1<​sup>​st</​sup>​ **Marriage Event** has 1<​sup>​st</​sup>​ **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 1<​sup>​st</​sup>​ **Birth Event** has 1<​sup>​st</​sup>​ or 2<​sup>​nd</​sup>​ **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 1<​sup>​st</​sup>​ **Baptism Event** has 1<​sup>​st</​sup>​ or 2<​sup>​nd</​sup>​ or 3<​sup>​rd</​sup>​ **Source Citation** with its **Title/​Name** containing **Baptism** ​  | 
-|         ​| ​          | 
-Typically **%INDI.XXXX...%** above can be replaced by **%FACT...%** in **Fact Queries**. 
- 
-Related Forum postings: 
-  * [[topic>​t=12570|Using expressions]] May 2015 
-  * [[topic>​t=12348|Marriage Icon]] February 2015 
- 
-==== 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: 
-  * [[topic>​t=12583|Adding Relationships to Reports]] May 2015 
-  * [[topic>​t=12570|Using expressions]] May 2015 
-  * [[topic>​t=12326|Display Relation to Root in a Named List Report]] February 2015 
-  * [[topic>​t=11879|Using flags to indicate...]] December 2014 
- 
-==== 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: 
-  * [[topic>​t=14953|Civil Partnership]] Apr 2017 
- 
-==== 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. For another example see the [[AncestralSources:​Family Historian Birth & Death Informant Witness Role]] **Facts Tab Format**. 
- 
-^ 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  | 
-|         ​| ​          | 
-{{fh}} **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: 
-  * [[topic>​t=13164|Sources,​ Citations, and Methods]] Dec 2015/Jan 2016 
-  * [[topic>​t=12275|Property Box - showing sources]] June 2015 
- 
-===== Related Pages ===== 
- 
-{{backlinks>​.}}