Formula Field Examples
Listed below are three examples of how formula fields are most commonly used: combining names, marking up a cost, and adding a number of days to a work order's Date Available. for PM work orders.
Combine Names
We'll call this example Person. This formula combines a person's last name and first name, with a comma separating the two names, so that the end result is a person's "last name, first name" in one column.
For this example, use a data source in the Work Ordersmodule.
-
Open the data source in which to use this formula by going to Data Sources > Query.
-
Once you open the necessary data source, click the Data Source Editor tab.
-
On the Designer sub tab, expand Related Tables > Assignments.
-
Drag the Resource Last Name and Resource First Name to the Column Area.
-
Hide both of these fields so that they will not display when the data source is generated.
-
Click Add Formula Field.
-
Select String Functions in the Functions and then STRINGPLUS.
-
A field titled Formula_1 appears in the column area. Click its Properties button.
-
In the Caption field, enter Person.
-
For String 1, click the toggle button next to the field and select Resource Last Name from the drop-down menu.
-
For String 2, enter a comma and a space (, ).
-
For String 3, the toggle button next to the field and select Resource First Name from the drop-down menu.
-
Click the Close button (the gray X in the upper-right corner of the Properties panel).
In the data preview, your formula field will display information like this: Smith, Carl.
Conversely, if you wanted to put the first name before the last name, follow steps 10 through 12 below.
-
For String 1, click the toggle button next to the field and select Resource First Name from the drop-down menu.
-
For String 2, enter a space.
-
For String 3, the toggle button next to the field and select Resource Last Name from the drop-down menu.
This would display the person's name as Carl Smith.
Mark Up a Cost
We'll call the second formula example Charge Cost. In this formula, a work order's total cost is marked up by a percentage to be charged to a customer.
For this example, use a data source in theWork Orders module.
-
Open the data source in which to use this formula by going to Data Sources > Query.
-
Once you open the necessary data source, click the Data Source Editor tab.
-
On the Designer sub tab, expand Summary Data.
-
Drag Total WO Cost to the Column Area.
-
Hide the field so that it won't display when the data source is generated.
-
Click Add Formula Field.
-
Select Mathematical Functions and then MULTIPLIED.
-
A field titled Formula_1 appears in the column area. Click its Properties button.
-
In the Caption field, enter Charge Cost.
-
Select a Summary Function if necessary.
-
Select a Mask for the data if necessary.
-
For Number 1, click the toggle button next to the field and select TotalWOCost from the drop-down menu.
-
For Number 2,enter the multiplication factor. For example, if you want mark up the cost by 25%, enter ".25".
-
Leave Number 3 blank.
-
Click the Close button (the gray X in the upper-right corner of the Properties panel).
Add on Days
We'll call the last formula example Due Date. In this formula, the Date Available of a work order has a number of days added to for PM work orders.
For this example, use a data source in theWork Orders module.
-
Open the data source in which to use this formula by going to Data Sources > Query.
-
Once you open the necessary data source, click the Data Source Editor tab.
-
On the Designer sub tab, expand Common Fields > Schedule.
-
Drag Date Available to the Column Area.
-
Hide the field so that it won't display when the data source is generated.
-
Click Add Formula Field.
-
Select Date Functions and then DATEADD.
-
A field titled Formula_1 appears in the column area. Click its Properties button.
-
In the Caption field, enter Due Date.
-
The Date Part field is where you select what you want to change: the day, week, month In this formula, we want to add 14 days to the date, so we will select Day from the drop-down menu.
-
In Value to Add, enter the number of days, months to add. We enter "14".
-
Click the Close button (the gray X in the upper-right corner of the Properties panel).