Expand my Community achievements bar.

Guidelines for the Responsible Use of Generative AI in the Experience Cloud Community.
SOLVED

Calculated field rounding inconsistency

Avatar

Level 1

Values in a calculated field are rounding inconsistently. A calculated value of 20.0755 rounds down to 20.07 but 19.855 rounds up to 19.86. Because the calculated value is an amount of currency, this inconsistency is causing accounting discrepancies.

Do I need to adjust the patterns? (I don't understand the differences between the patterns available.)

I have tried using the Round function in FormCalc and Math.Round in Javascript with no change in results.

Thanks!

1 Accepted Solution

Avatar

Correct answer by
Former Community Member
6 Replies

Avatar

Former Community Member

Can you post a sample that shows the issue?

Paul

Avatar

Level 1

Here's the file. The field in question is Amount_Personal_Mileage on the first page. The field displays the product of the "Miles" field and 0.55.

36.1 entered in "Miles" results in a correct "Amount_Personal_Mileage" display value of 19.86.

36.5 entered in "Miles" results in a "Amount_Personal_Mileage" display value of 20.07.

Thanks.

Avatar

Former Community Member

The pattern that you are applying to the fields does not round  - it simply truncates. For the total field you are saying that you only want two digits. If you want to round it up you can add the round function to the calculation:

In Javascript it woudl be:

In FormCalc it woudl be:

Paul

Avatar

Level 1

Sorry to be dense, but I still get the same results. Do I need to set a pattern for the results field? If so, which one includes the dollar sign but doesn't truncate? ---Kat

Avatar

Correct answer by
Former Community Member

Here is an updated sample

Paul

Avatar

Level 1

Thank you! You saved me from beating my head against the wall.---Kat

The following has evaluated to null or missing: ==> liqladmin("SELECT id, value FROM metrics WHERE id = 'net_accepted_solutions' and user.id = '${acceptedAnswer.author.id}'").data.items [in template "analytics-container" at line 83, column 41] ---- Tip: It's the step after the last dot that caused this error, not those before it. ---- Tip: If the failing expression is known to be legally refer to something that's sometimes null or missing, either specify a default value like myOptionalVar!myDefault, or use <#if myOptionalVar??>when-present<#else>when-missing. (These only cover the last step of the expression; to cover the whole expression, use parenthesis: (myOptionalVar.foo)!myDefault, (myOptionalVar.foo)?? ---- ---- FTL stack trace ("~" means nesting-related): - Failed at: #assign answerAuthorNetSolutions = li... [in template "analytics-container" at line 83, column 5] ----