Peter Barfield Posted April 14, 2016 Posted April 14, 2016 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
comment Posted April 14, 2016 Posted April 14, 2016 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. 1
Peter Barfield Posted April 14, 2016 Author Posted April 14, 2016 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.
comment Posted April 14, 2016 Posted April 14, 2016 (edited) 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, 2016 by comment
LaRetta Posted April 14, 2016 Posted April 14, 2016 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() !!!! :-)
comment Posted April 14, 2016 Posted April 14, 2016 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
Recommended Posts
This topic is 3411 days old. Please don't post here. Open a new topic instead.
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now