Report - formulas
- Last UpdatedFeb 23, 2023
- 2 minute read
You can use formulas in Crystal Reports. Use the Formula fields to create them. Formulas can be added in Crystal or Basic syntax. If the formula starts with "formula = ", it is Basic syntax.
Example
An example of a formula is this page numbering using the page X of Y notation:
formula = "page " & cstr(PageNumber,0) & " of " & cstr(TotalPageCount,0)
Time Format Formula
In Asset Strategy Optimization you can assign times to maintenance actions. These times can be entered in hours, weeks, months and years. The times are stored in hours in the Asset Strategy Optimization database. The format they were entered in is also saved. It is preferable for reports to display the times in the format they were entered in, instead of in hours. You can use the time format formula to convert a time from hours to the original notation.
This formula has been added to the reports that are supplied with the Report module.
Example - failure duration
An example is the display of the failure duration:
formula = period2string({FMECARISK.MAINMAINT__smn_pmInterval},{FMECARISK.MAINMAINT__smn_pmInterval_stt_ID})
Period2string is the time format formula; it requires two parameters:
-
The field with the entered value
In this case it is {FMECARISK.MAINMAINT__smn_pmInterval}.
This field contains the entered value (of the Interval) in hours. -
The chosen time format
In this case it is {FMECARISK.MAINMAINT__smn_pmInterval_stt_ID}
(The field is indicated with the same name followed by _stt_ID)
This field contains the entered time format (of the Interval) as a number; it can be:-
Hours
-
Weeks
-
Months
-
Years
-
Example of effect
formula = period2string({FMECARISK.MAINMAINT__smn_pmInterval},{FMECARISK.MAINMAINT__smn_pmInterval_stt_ID})
Where pmInterval has the value 9 , and pmInterval_stt_ID has the value 3.
In the database the field pmInterval is stored as 6570 hours. The formula period2string converts this to the format of stt_ID; value 3 months.
The value of pmInterval, after conversion to months, comes in the field of the formula as 9 months.