# Calculate Expressions - The Master List

edited December 2018
This thread contains a list of common Calculate Expression examples used within a Field in a Data Model.

## Examples

• Quantity * Unit_Price - This field should equal the 'Quantity' field times the 'Unit Price' field.
• Math.Round(Quantity * Unit_Price,2) - Same as above, but with rounding.
• Line_Items.SumOf("Line Total") - This field should always equal the sum of the 'Line Total' column in the 'Line Items' table.
• Semester.SumOf("Total Hours") - This field should always equal the sum of the 'Total Hours' field from all instances of the 'Semester' section.
• GetFieldInstance("Invoice No").Value - Returns the value of the Invoice No field. The target field is identified by passing in its Name or GUID as a string value.
• Utilities.CalculateValue(Instance) - Calls an Object Library to perform an action on the current Instance. 'Utilities' is the Object Library Name and 'CalculateValue' is the Method Name.
• FieldA & "-" & FieldB - Concatenates the values of two fields in the Data Model, and adds a literal hyphen character between the two. In this case, each field has a base type of String.
• DateDiff(DateInterval.Minute, CDate(Start_Time), CDate("12:30")) / 60.0 - This field, which is a decimal, should equal the difference between two times, which in this case are a field named "Start_Time" and a static time of 12:30pm. Props to @Brian for this one.
• ParentInstance.InstanceNo + 1 - When used on a Data Field that is a direct child of a Data Section or a Data Column that is a direct child of of a Data Table, returns the position of the current item. As an example, if a table has 10 rows on a given document, this would return the line number of the current line.
Matt Harrison
Director of Strategy
[email protected]