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

Steven,
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:
 Show the age with more than 0 decimals
 Determine the age based on the first charachters, but it turns into a text field then
 Determine between which numbers the age lies and extract the nodecimalage from that (my preference, it’s easier to search for on table pages)
Option number 1:
Store the age in a dataitem 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:
 Convert it to a text
 Determine where the decimal is
 When it’s at position 3, the age is higher than 9
 Else it’s below 10
 Number of item 2 minus 1
 Cut the charachters untill the position in step 3
Let’s use an example for this. The age is 8.92
 Calculation: Use the function COMBINE “8.92” WITH “”(fill out nothing as a specific value in the second part)
 Calculation: CUT [Step 1] FROM “1” FOR “2” CHARACHTERS > Result = “8.”
 Calculation: TEXT [Step 2] CONTAINS “.” > Result = “true”
 If there’s a “.” in the first two charachters the age is below 10, which is true in this case
 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:
 Create a dataitem with two properties Age min and Age max with 0 decimals
 Create an Excel with 2 colums. Fill this Excel with corresponding ages
 Determine between which values the age lies
 Select the referenced/corresponding value
Let’s use an example for this. The age is 8.92
 Create the dataitem “Calculate age” with the properties “Age min” and “Age max” which are numbers with 0 decimals. This dataitem whould be marked as importable (see https://triggre.com/knowledgebase/creatingdataitems/ for more info)
 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 dataitem created in [Step 1]
PS: Use the wizard at Create User flows to create a user flow to import Excels (see https://triggre.com/knowledgebase/usingtheuserflowwizard/ for more info)  Import this Excel
 Create a lookup in your flow part and retrieve a single value. This lookup uses the following filter: [Input Age] >= [Age min] AND [Input Age] < [Age max]
 The age will be the [Age min] of the lookup. (see marked item in image below)