6 Replies Latest reply on Sep 29, 2014 3:53 PM by tc_fmdev

# extract the 1st 2nd 3rd etc value of a number

### Title

extract the 1st 2nd 3rd etc value of a number

### Post

I have a number that has 4 places to the right of decimal example:  98765.4321

I am trying to extract each position from the right into a field

So i have a field ready for each position

1 =1      2=2      3=3     4=4      5=.      6=7     7=8   etc etc

I tried right but it is picking up x-number of characters...but I only need the 1 character/value from each.

I thought this would work but it is doing the same as Right.

RightValues ( Right ( MyField ; 1 ) ; 1 )

T

• ###### 1. Re: extract the 1st 2nd 3rd etc value of a number

Try using the Middle function with a "length" parameter of 1.

• ###### 2. Re: extract the 1st 2nd 3rd etc value of a number

Ok .

I'm re-mapping my direction of count... seems like filemaker right likes to go the same direction as left and my number length changes

so number example

1,234,456 . 89 (10)(11)

where my 7th field is always a . decimal point

going to see if this starts to work

• ###### 3. Re: extract the 1st 2nd 3rd etc value of a number

You may need to pad with zeroes or use the position function to return the position of the period.

Right ( "000000" & Int ( YourNumberHere ) ; 6 )

will return all digits to the left of the decimal with leading zeroes added.

YourNumber - Int ( YourNumber )

will return the decimal and the digits to the right of the decimal

• ###### 4. Re: extract the 1st 2nd 3rd etc value of a number

I have it working from right to left using :

Field 1 - Right ( MyField ; 1 )

Field 2 - Left ( Right ( MyField) ; 2); 1)

Field 3 - Left ( Right ( MyField) ; 3); 1)

Field 4 - Left ( Right ( MyField) ; 4); 1)

Field 5 - Left ( Right ( MyField) ; 5); 1)     //THIS FIELD IS DECIMAL POINT

Field 6 - Left ( Right ( MyField) ; 6); 1)

Field 7 - Left ( Right ( MyField) ; 7); 1)

Field 8 - Left ( Right ( MyField) ; 8); 1)

Field 9 - Left ( Right ( MyField) ; 9); 1)

Field 10 - Left ( Right ( MyField) ; 10); 1)

Field 11 - Left ( Right ( MyField) ; 11); 1)

Field 12 - Left ( Right ( MyField) ; 12); 1)

however....

if MyField number is shorter in length than 12 characters...then the fields that are supposed to be blank get filled with the first number

for example....

231.4456

currently it is producing....

F12=2 (wrong)     F11=2 (wrong)     F10=2 (wrong)   F9=2(wrong)    F8=2 (correct)    F7=3(correct) F6=1(correct) F5=.(correct)       F4=4(correct)     F3=4(correct)     F2=5(correct)   F1=6(correct)

so it works....kind of....

I need to address the F12 F11 F10 F9 and my thought is to place a test in every field to check the LENGTH

in this case LENGTH = 8    ..therefore if the LENGTH is 9 10 11 or 12 the calc should place a "" (blank)

so this would be the calc in field 10.....but it doesn't seem to be working

Case (

(Length ( MyField )   ≥  10); "0";

Left ( Right ( MyField ; 10 ) ; 1 )

)

• ###### 5. Re: extract the 1st 2nd 3rd etc value of a number

Seems like the middle function would be simpler:

Field 1: Middle ( MyField ; Length ( MyField ) ; 1 )
Field 2: Middle ( MyField ; length ( MyField ) - 2 ) ; 1 )

and so forth...

• ###### 6. Re: extract the 1st 2nd 3rd etc value of a number

PhilModJunk,

Thank you.   I did not fully understand the middle function and that it can be calculated backwards with negative.

Much cleaner and the way I like it.

I did get it all working because of your time and assistance today.

Thank You

Much Appreciated

TC