Custom Calculations
You can run complex logic and calculations on your web app by creating by using custom calculations under derived fields. This feature helps you run complex computations on your data.
How to Create Custom Calculations Derived Field?
1. Open the Collection Settings
Go to the Collections panel and open the settings of the collection to which you want to add a derived field for custom calculation.
2. Go to Derived Fields
As you land on the collection's settings page, you will different settings in the form of tabs. So go to the derived fields tab and click on it.
3. Select Method Type
To create a derived field, start by naming it and then select Custom Calculation as the method type.
4. Add the Custom Logic or Formula
After selecting the method type, add your custom logic or formula and click the Create button.
Remember, keep the name of a field while creating a logic between double curly brackets, for e.g. ({{opening_stock}}+{{inward}})-{{outward}}. Also, use the field name as displayed in the backend code which will pop up by clicking the View icon.
5. Bind the Collection to a Data Table
Open the settings and click on Get Content. Select Get Content from Collection. Then select the collection in which you have create a custom calculation derived field.
6. Add a Field in the Data Table
To add a derived field, you have to duplicate an existing field. So select an existing field and click on the duplicate icon as shown below.
7. Bind the Derived field
Once you have duplicated an existing field, open the settings of the duplicated table cell and select the custom calculations derived field to bind it to the cell.
8. Preview or Publish
Now open the page in the preview or the publish mode. You will see the custom calculation derived field would show the calculated data as per the logic or formula you added.