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 of how to set a formula, 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 with a formula set to produce a "Subtotal" value by multiplying the values in the "Unit price" and "Quantity" fields

  1. Click the App Settings icon (the gear-shaped icon at the upper right of the app's "View" screen), then select the Form tab.
    Screenshot: The "App Settings" icon is outlined in red

  2. 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

  3. 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

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

  5. 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

  6. Click Save.

  7. 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

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

  9. Enter "Quantity" in the Field Code input field. Screenshot: The "Name" and "Field Code" sections are outlined in red on the "Number Settings" screen

  10. Click Save.

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

  12. 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

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

  14. 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

  15. Click Save.

  16. Click Save Form on the upper left side of the screen.

  17. If you are creating a new app, click Activate App at the upper right of the screen and click OK on the confirmation dialog.
    If you are changing the settings of an existing app, click Update App at the upper right of the screen and click Update App on the confirmation dialog.

Now you have completed setting the formula.
When you enter a unit price and quantity on the "New Record" or "Edit Record" screen, 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.