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

Round function

Featured Replies

I have a calculation field that has this calculation on it.

(At0 +

At1 +

At2 +

At3 +

At4 +

At5 +

At6 +

At7 +

At8 +

At9 +

At10 +

At11 +

At12 +

At13 +

At14 +

At15 +

At16) / Length

The problem is, is that I frequently get decimals with this function. Is there a way to add a round function to this? Every time I try FileMaker tells me that its looking for a field not a calculation. Any help you can give is much appreciated.

Is Length a field? Or a number? It shouldn't be a field name because it's also a function. But try this:

Round (

( At0 +

At1 +

At2 +

At3 ) / number ) ; 0 )

You didn't specify your rounding desires - there are many variations of the desired result. Without more information, I can't be more exact but I hope this gets you moving in the right direction. If not let us know and we'll help you further.

I must say, Heathbo, that having that many fields to add together certainly indicates improper relational structure. (signed) Soren :wink2:

... for LaRetta ... :laugh2:

  • Author

Sorry LaRetta. Length is a field. and 0 works fine.

  • Author

I must say, Heathbo, that having that many fields to add together certainly indicates improper relational structure. (signed) Soren :wink2:

... for LaRetta ... :laugh2:

All of those fields are different stages of the same record. Not all the stages have a value. Length is a count of how many stages have a value. Based on this, my purpose of this calculation was to create an average value of all the stages with values.

I repeat the above just as firmly - this same math and testing can be handled in records and would work much better!

But hey ... it was rude of Soren to jump into our thread anyway!! :giggle:

Soren knows I'm kidding him ... but I'm serious about totally agreeing this time ... You will be repeatedly writing these types of long calcs (which need to be modified any time you add a field) instead of letting FM do what it does best ... sum related, count, perform math, and provide statistics. I'd even rather see you go to Repeaters here than fields. And expect to write a thousand more calcs just like this - and don't expect to EVER produce a logical report grouping by stage.

Hey. I say this because I like you. If I didn't give a rip, I wouldn't even post, right?

LaRetta

  • Author

OK, well, knowing what you know, how would your write this calculation?

All of those fields are different stages of the same record. Not all the stages have a value. Length is a count of how many stages have a value. Based on this, my purpose of this calculation was to create an average value of all the stages with values.

Records. They would be records in a Stage table with a foreign key of the main record and a serial field and a text field for the TYPE of stage (or level) and a VALUE field (number). Test the relationship for existance of stage record with If ( not IsEmpty(serial) . Then count them with, ummm, yep ... Count(Stage::Serial) and possibly Sum(Stage::Value) ... Apply your math like Average = Div( value ; count) ... and providing value lists for popups or filtered portals by Stage::Type and generating nifty instant reports grouping any-which-way-but-loose but particularly to evaluate multiple main records' various stages against each other. Reporting from your Stage table allows summaries to carry the weight and decrease the aggregate needs.

Possibilities are endless. Flexibility is maximized. Math is simple. Your sanity is saved and you'll have a lot more time for other things than typing the field names repeatedly or attempting to find convoluted calculations to solve problems that shouldn't exist to begin with. And I didn't even have to THINK about that one! I just gave you an entire structure in the time it took you just to TYPE your fields for this ONE calculation ... :wink2:

LaRetta

Create an account or sign in to comment

Important Information

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

Account

Navigation

Search

Search

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.