Jump to content
View in the app

A better way to browse. Learn more.

FMForums.com

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

How to force calculation in layout to round to two decimals

Featured Replies

I have a layout calculation that looks like:

Round(If($$NoGPABump = 1;Classes::GPANoBump; Classes::GPABumped);2)

In most instances, this rounds the appropriate value to 2 decimals  and displays those two digits.  But on occasion, it displays only one decimal as in this one:

image.png.c71290d1f0c6315902aaa0345baf7865.png.  Instead I want to see 4.20.  If I round to, say, 4 decimals, it works properly: image.png.a36b87c5140fbfdcbfdd61fa17c68447.png.  Rounding to 3 digits gives 4.199.  How do I get the trailing zero to show up?  This seems to be consistent for all data that rounds to a last digit of zero.  Is this a bug?  Is there a workaround?  Thanks,

 

Set the layout object to display as a numeric with 2 decimals (using the inspector).

  • Author

Thank you Kaizentu.  In this case the layout object is a button bar with a conditionally calculated title and there is no option to set the format of the object.  I've gotten used to using that technique a lot to display conditional or calculated text.  It's a great way to avoid creating another calculated field but seems to have this limitation.  I went back to the workaround for this - two instances of the field superimposed, using "Hide object when" to display the relevant one.  Any other option?  Thanks

You can do your own formatting within the calculation, for example:

Let ( [
n = If ( $$NoGPABump = 1 ; Classes::GPANoBump ; Classes::GPABumped ) ;
r = Round ( n ; 2 )
] ;
Int ( r ) & SerialIncrement ( ".00" ; 100 * Mod ( r ; 1 ) )
)

Note that this assumes the number is not negative - otherwise the calculation needs to be a bit more complex.

 

  • Author

Wow, that's cool.  I never considered brute force calculating the formatted text.  I suppose I could write a custom function to support formatting rounded to a given number of decimals.  I guess I'm spoiled and used to platforms that have that kind of functionality built in.  For this one, however, I think the easiest solution is to use the field formatting with conditional visibility rather than the calculation.  Not too bad!

Thanks for the help

Create an account or sign in to comment

Important Information

By using this site, you agree to our Terms of Use.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.