Basics of Using Formulas

Article Number:040509

By setting a formula in an app, you can calculate the sum of multiple values or have a value automatically displayed according to conditions specified in a function.
This page describes the basics of using and setting up formulas.

Formula basics

It is necessary to understand the following three points when using formulas.

Formulas are entered on the settings screens of "Calculated" and "Text" fields

Formulas can be used only with Calculated and Text fields.
Use a Calculated field if you want the calculation result to be treated as a numeric value, or use a Text field if you want the result to be treated as a string value.

Field codes are used to refer to fields in a formula

A field code is a string used for identifying a field. In formulas, field codes are used to refer to other fields.
For details, refer to the following pages.
Overview of field codes
Fields that can/cannot be referenced in formulas

Clicking Insert field code displays a list of the field codes that exist in the app you are using.
Select a field code from the list to have it entered in the Formula input field. Screenshot: The screen for setting a formula. The "Insert field code" button and a list of field codes are outlined in red.

Formulas use functions and operators

Formulas in kintone support half-width operators (e.g., "+", "-", "*", "/"), as well as functions.
You can use multiple operators and functions together in a single formula.
List of operators and functions

Clicking Insert function displays a list of the functions you can use in kintone.
Select a function from the list to have it entered in the Formula input field. Screenshot: The screen for setting a formula. "Insert function" and the listed functions are outlined in red.

How to set formulas

As an example, this section walks you through setting up a formula that multiplies a unit price and quantity to produce a subtotal.
You will use Number fields for entering numeric values, and a Calculated field for displaying the calculation result.

Screenshot: An app set with a formula that calculates the value of a "Subtotal" field by multiplying the values of "Unit price" and "Quantity" fields

  1. Click the App settings icon (the gear-shaped icon) at the upper right of the View screen.
    Screenshot: The "App settings" icon is highlighted

  2. On the App settings screen, click the Form tab.

  3. Place two Number fields on the app form by dragging the Number field displayed in the list of fields on the left side of the screen and then dropping it onto the area on the right side of the screen. Screenshot: Two "Number" fields are placed on a form

  4. Open the settings screen of the Number field that will be used for entering a unit price. To do so, click the Settings icon (the gear-shaped icon) at the upper right of the Number field, then click Settings. Screenshot: "Settings" at the upper right of a "Number" field is outlined in red

  5. Enter "Unit price" in the Name input field.

  6. Enter "Unit_price" in the Field code input field. Screenshot: The "Name" and "Field code" sections are outlined in red on the "Number settings" screen

  7. Click Save.

  8. Open the settings screen of the Number field that will be used for entering a quantity. To do so, click the Settings icon (the gear-shaped icon) at the upper right of the Number field, then click Settings. Screenshot: "Settings" at the upper right of a "Number" field is outlined in red

  9. Enter "Quantity" in the Name input field.

  10. Enter "Quantity" in the Field code input field. Screenshot: The "Name" and "Field code" sections are outlined in red on the "Number settings" screen

  11. Click Save.

  12. Place a "Calculated" field on the app form. Screenshot: The app form

  13. Open the settings screen of the Calculated field. From the Settings icon (the gear-shaped icon) at the upper right of the Calculated field, click Settings. Screenshot: A field's "Settings" icon

  14. Enter "Subtotal" in the Name input field.

  15. Enter the following formula in the Formula input field.

    The content has been copied.
    Unit_price*Quantity

    Screenshot: The "Name" and "Field code" sections are outlined in red on the "Calculated settings" screen

  16. Click Save.

  17. Click Save form on the upper left side of the screen.

  18. If you are creating a new app, click Activate app and click OK on the confirmation dialog.
    If you are changing the settings of an existing app, click Update app and select Update app on the confirmation dialog.

When you enter a unit price and quantity on the screen for adding or editing a record, the calculation result will appear in the "Subtotal" field.

If an error message appears

If an error message appears when setting a formula or entering data on a record, refer to the following pages for solutions.