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.

Defining field in 8ths fractions

Featured Replies

  • Newbies

Hi Folks! I am a brand new FM7 user! And I am a quick learner... but... I need some fast help with this issue (I know I could figure it out by myself in a week's time, but I need to do it faster).

I need to define a field (in a record) that stores a number in 8ths (fractions) -- like I can easily do in Excel. For example that field in 5 different records might look like this

RECORD 1: 1 1/8

RECORD 2: 3 5/8

RECORD 3: 4 4/8 (notice that's not 1/2!)

RECORD 4: 2 7/8

RECORD 5: 5 3/8

Later... I will have a new layout that will have a field that will total those records (17 4/8)... but that is not as critical to my question today.

And... I want to enter those values exactly as you see them (in 8ths... not 1.125, 3.625, etc.)

I looked at this forum topic, but couldn't figure it out to suit my specific needs:

http://www.fmforums.com/forum/showtopic.php?tid/192065/

Thanks for any help!!!

I believe the thread you linked to has all the answers - what more do you need to know? There is no way to define a field that way - to Filemaker, "2 7/8" is just a text string with no meaning.

To total the values, you will need a second field that will translate each string into a numerical value that Filemaker can understand.

Which could look something like this:

Let ( [

@number = Trim(number);

@integer = LeftWords(@number;1);

@integer = If(@integer = @number;0;@integer);

@denominator = Right ( @number ; Length(@number)-Position(@number; "/";1;1 ));

@numerator = Middle ( @number ; Position ( @number ; " "; 1 ; 1 ) ; Position ( @number ; "/"; 1 ; 1 )-Position ( @number ; " "; 1 ; 1 ) )

];



Case(

// no slash, so no fraction

PatternCount(@number;"/")=0;@number;



// too many spaces, so no valid fraction

PatternCount(@number;" ")>1;@number;



// - we have a fraction to parse

@integer + (@numerator/@denominator)

 )

)

You'd probably want to just put validation on your fraction fields, rather than do the preflight checking for slashes etc. I'm basically punting when malformed fractions are entered, and just spitting back the original value, so if you enter "11 space space space 1/8" it won't work.

Michael will probably be disgusted with this and reply with two lines of code that do the same thing :

Michael will probably be disgusted with this and reply with two lines of code that do the same thing :

True enough - except I already did this in the above-mentioned thread (and it's a one-liner):P

http://www.fmforums.com/forum/showpost.php?post/275809/

As for making sure the data conforms to the format, I'd suggest doing this at the time data is entered. An auto-entered (replace) calc =

TrimAll ( Filter ( entry ; "0123456789 /" ) ; 0 ; 0 )

should take care of the most obvious typos.

All I can say is...sweet.

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.