April 14, 20169 yr Quick Quesstion, I have a number that I want to be formatted automatically upon entry to keep everything the same. The number is 11 characters and broken up as 2,3,3,3 or eg 11 111 111 111. Now I have used a calculation Let( @NumbersOnly = Filter(Self; "0123456789"); Case( Length(@NumbersOnly) = 10; "("&""& Left (@NumbersOnly; 2) &")"& "" &" "& Middle(@NumbersOnly;3;4) & "-" & Right (@NumbersOnly;4) )) to format a phone number specifically and that is fine. But for the love of Mike how would I break up thea bove example to the 11 111 111 111 format when enterd as 11111111111
April 14, 20169 yr Here's one way: Let ( digits = Filter ( Self ; "0123456789" ) ; Left ( digits ; 2 ) & " " & Middle ( digits ; 3 ; 3 ) & " " & Middle ( digits ; 6 ; 3 ) & " " & Right ( digits ; 3 ) ) Here's another: Let ( digits = Filter ( Self ; "0123456789" ) ; Replace ( Replace ( Replace ( digits ; 9 ; 0 ; " " ) ; 6 ; 0 ; " " ) ; 3 ; 0 ; " " ) ) I did not test for length, because you didn't say what should be done when the test fails. In your example, the entry would have been erased - which is kind of cruel to the user.
April 14, 20169 yr Author Thanks Comment, I have a cruel streak Not really! I hadn't Picked up on that so will look but I will try your suggestion. I guess I wasn't sure how to deal with the 2 middle arguments. I wasnt sure if you could only have 1 instance but from your suggestion it appears that you can "nest" them for want of a better word. Thanks for your help as usual always prompt.
April 14, 20169 yr You can concatenate as many Middle() function calls as you need. The name Middle does not refer to your calculation; it refers to the string from which the function will extract a "middle" part (unlike the Left() or Right() functions, which will only extract a part from one of the string's ends). Edited April 14, 20169 yr by comment
April 14, 20169 yr 10 hours ago, comment said: Here's another: Let ( digits = Filter ( Self ; "0123456789" ) ; Replace ( Replace ( Replace ( digits ; 9 ; 0 ; " " ) ; 6 ; 0 ; " " ) ; 3 ; 0 ; " " ) ) Nice use of Replace() !!!! :-)
April 14, 20169 yr 35 minutes ago, LaRetta said: Nice use of Replace() !!!! Credit: http://fmforums.com/topic/32095-how-to-format-a-numerical-field-to-show-as-smpte/?do=findComment&comment=145473
Create an account or sign in to comment