Reply To: Roundings in calculations

Forums Designer Building applications Roundings in calculations Reply To: Roundings in calculations

    Eddie Heijblom


    Rounding is automatically executed in Triggre. In the first case the value will be something like 8.92 which is rounded to 9. Which is a standard rounding. To get the result you’re looking for you have three options:

    1. Show the age with more than 0 decimals
    2. Determine the age based on the first charachters, but it turns into a text field then
    3. Determine between which numbers the age lies and extract the no-decimal-age from that (my preference, it’s easier to search for on table pages)

    Option number 1: 

    Store the age in a data-item with a property with more than 0 decimals.

    Option number 2:

    Let’s assume someone can’t get older than 99, for this example. You can extend this to > 100 by adding another decision to your flow part.

    We need to do the following steps:

    1. Convert it to a text
    2. Determine where the decimal is
      1. When it’s at position 3, the age is higher than 9
      2. Else it’s below 10
    3. Number of item 2 minus 1
    4. Cut the charachters untill the position in step 3

    Let’s use an example for this. The age is 8.92

    1. Calculation: Use the function COMBINE “8.92” WITH “”(fill out nothing as a specific value in the second part)
    2. Calculation: CUT [Step 1] FROM “1” FOR “2” CHARACHTERS -> Result = “8.”
    3. Calculation: TEXT [Step 2] CONTAINS “.” -> Result = “true”
    4. If there’s a “.” in the first two charachters the age is below 10, which is true in this case
    5. Calculation: CUT [Step 1] FROM “1” FOR “1” CHARACHTER -> Result = “8”

    Option number 3:

    The concept behind option number 3 can be very usefull in other situations as well. The general idea behind it is that we look up the value in a table and use a referenced value linked to that table.

    We need to do the following steps:

    1. Create a data-item with two properties Age min and Age max with 0 decimals
    2. Create an Excel with 2 colums. Fill this Excel with corresponding ages
    3.  Determine between which values the age lies
    4. Select the referenced/corresponding value

    Let’s use an example for this. The age is 8.92

    1. Create the data-item “Calculate age” with the properties “Age min” and “Age max” which are numbers with 0 decimals. This data-item whould be marked as importable (see for more info)
    2. Create an Excel. This Excel has two columns “Age min” and “Age max”. Also the name of the work sheet should be exactly the same as the name of the data-item created in [Step 1]
      PS: Use the wizard at Create User flows to create a user flow to import Excels (see for more info)
    3. Import this Excel
    4. Create a look-up in your flow part and retrieve a single value. This look-up uses the following filter: [Input Age] >= [Age min] AND [Input Age] < [Age max]
    5. The age will be the [Age min]  of the look-up. (see marked item in image below)
      forum explain

Get started for free and experience the power of the Triggre platform.

By signing up for your free account, you agree to receive e-mails from Triggre.

By using our site you agree to our use of cookies to deliver a better site experience.