How do I set up formulas using the iPhone Formula Engine?
Do NOT use Numerals in any Attribute Name , these are not usable within a formula and can cause the app to hang, slowdown or crash.
Setting up formulas
Restore FDG app on mobile and go to any route-> stop-> stop Object -> click on the name on the navigation bar on top. Copy the Reading View.
Go to Admin.
Go to Reading Types on the left pane, and then go to Reading Views.
Search for the name of the Reading View you copied in the search bar on top right.
Click on the Reading View and the related attributes configured with the Reading View display at the bottom.
Click on the attribute for which you want to set the formula and click edit.
Calculation formula: Check Calculated and enter the expression in the formula textbox, for example, if([TubingPressure]>100,100,[TubingPressure])
Carryforward formula: Select Carryforward type in the dropdown and enter expression in the Carryforward formula textbox, for example, if([TubingPressure]>100,100,[TubingPressure])
Custom validation formula: Enter expression in the Validation formula textbox, for example, IsNull([Comments]);"Please Enter valid comments"
Custom formatting formula: Enter expression in the formatting formula textbox, for example, SHOW_IF([CasingPressure]>100)
Click Update.
Restore route of the object in which you made the changes in Admin so that your changes are reflected in the app.
Edit any value for the same object to check if the updated formula is working correctly or not.
Constraints
Attribute names are supported in the format of [AttributeName] in custom validation and custom formatting. For calculation and carryforward, both [ReadingTypeName].[AttributeName] and [AttributeName] are supported.
Picklist value/names for reading attributes is supported as [DowntimeReason].Name == 'Yes' and Picklist value is only supported when the picklist is part of a EAV attribute of the object.
Calculation and carryforward are the same for all workspace readings. Calculations for events and tickets are handled differently which only supports daysFromLastReading and ADDDAYS and normal expression.
# | Name | Description | Usage | Validation | Formatting | Carry-forward | StopObjectEAV | Exceptions |
|---|---|---|---|---|---|---|---|---|
IF | Follows- if(condition,true_statement,false_statement) If Tubing Pressure was 120, this expression will return 100 if Tubing Pressure is less than 100, will return the value of Tubing Pressure. Stop Object eav and Mass cf are not supported in inside if(...) condition. | if([TubingPressure]>100,100,[TubingPressure]) |
|
|
|
| ||
DATEDIFF | Returns difference in days between 2 dates. | DATEDIFF([UserDate1],[UserDate2]) Not Supported
|
|
|
|
|
| |
ADDDAYS |
| ADDDAYS([UserDate],n) Not Supported
|
|
|
|
| Formulas involving constant dates (not coming from a variable) are not supported | |
ISNULL | return true if no value is present | isnull([COMMENTS]) |
|
|
|
| ||
ADDHOURS |
|
|
|
|
|
| ||
VARIANCE | calculates average of n readings and compare current Volume value and returns the absolute difference between both | VARIANCE([Volume],n) |
|
|
|
| ||
AVERAGE | will return average of last n readings, if some readings don't have value, for eg:- only 6 out of n readings have value, will add 6 readings and calculate their average only | AVERAGE([Volume],n) |
|
|
|
| ||
SUM | It calculated sum of last n days reading, if some readings don't have value, for eg:- only 6 out of n readings have value, will add 6 readings only. | SUM([Volume],n) |
|
|
|
| ||
DAYS_FROM_LASTREADING | get days difference between current date and last known reading having some data | DAYS_FROM_LASTREADING() |
|
|
|
| ||
SHOW_IF | Syntax: SHOW_IF(Condition) If the condition evaluates to true, show the attribute that this is set as a formatting formula for. If the condition evaluates to false, the negation is Hide_and_clear_if which will hide(disable) the attribute and clear the attribute's value. On the workspace screen, since we can't hide one attribute for one day and show it on another day, we disable them. On events/tickets screen, we show/hide them. | SHOW_IF([CasingPressure]>100) |
|
| ||||
HIDE_IF | Syntax: HIDE_IF(Condition) If the condition evaluates to true, hide(disable for workspace screen) the attribute that this is set as a formatting formula for. If the condition evaluates to false, the negation is Show_if which will show the attribute. On the workspace screen, since we can't hide one attribute for one day and show it on another day, we disable them. On events/tickets screen, we show/hide them. | HIDE_IF([CasingPressure]>100) |
|
| ||||
ENABLE_IF | Syntax: ENABLE_IF(condition). If the condition evaluates to true, Enable the attribute for data entry. If condition evaluates to false, the negation is Disable_and_clear_if which will clear the value and disable the attribute for data entry. | ENABLE_IF([CasingPressure]>100) |
|
| ||||
DISABLE_IF | Syntax: DISABLE_IF(condition). If the condition evaluates to true, Disable the attribute for data entry without clearing the existing value. If condition evaluates to false, the negation is Enable_if which will enable the attribute for data entry. | DISABLE_IF([CasingPressure]>100) |
|
| ||||
DISABLE_AND_CLEAR_IF | Syntax: DISABLE_AND_CLEAR_IF(condition). If the condition evaluates to true, disable the attribute for data entry and clear the existing cell value. If condition evaluates to false, the negation is Enable_if which will enable the attribute for data entry. | DISABLE_AND_CLEAR_IF([CasingPressure]>100) |
|
| ||||
Reading level metadata | Syntax: [Reading].[columnname] We can access reading level field values using this syntax | Example: IsNull([Reading].[ReadingNumber]) |
|
|
|
|
| |
Object level metadata | Syntax: [Well].[ProducingMethod] / [Meter].[InstalledOn] etc We can access object level properties (both EAV and columnar properties) using this syntax | Example: ADDDAYS([Meter].[InstalledOn],5) |
|
|
|
|
Related Articles
- What functions are supported in calculated measures?
- How do I update my Analytics report subscriptions
- How do I set up formulas using the iPhone Formula Engine?
- Can I use Asset level attributes in formulae for reading level attributes?
- Do formatting formulae work on readings management from the Admin?
- How do I configure formatting formula to work on the mobile app?