You can use formula field in Crystal report for a custom field, for example
- You want to find total sales based Qauntity and units sold
- You want to multiply, add two numbers
- You want to add number of days to the current date
Note that Crystal Report formula fields are not function but they act like one. They do not declare any input variables or parameters and you do not declare any output variable or return a value. All is taken care of in the editor without declaring anything.
Right click on Formula fields and select New. Choose a name for your field. Start editing.
Drag any field from the available fields and use it in the formula. These act as input fields.
No need to return a value. What ever is the product of the calculation will be return when you use Formula field
Example : Add 7 days to current date
Right click on Formula field, just below Database Fields. Choose the formula field name
In the popup dialog and editor, in the middle column (Function field), select Date Time and expand that selection by clicking + in front of it. Double click two functions that we we will need, DateAdd and Current Date. Give it proper parameters. consult documentation for proper syntax. When done clic on X-2 syntax check mark to make sure all is ok. If no error is found, save the document and close.
The screenshot and formula in this case happens to be the following
Note that there is no return type or any return value.