Slobey Posted November 19, 2007 Posted November 19, 2007 Hi everyone, I am trying to create a field that will count only the letters in another field. I have tried different formulas to count them using getastext, filtervalues patterncount and substitute but can't figure it out. Basically if field a contains an alpha character (a-z) I want just the number of those characters to show up in field b. For example: field a contains 11a24b field b would show 2 field a contains Pend12 field b would show 4 Any ideas? Thanks Mike
Slobey Posted November 19, 2007 Author Posted November 19, 2007 I got it. Length(field1) - length(getasnumber;field1)) Unless someone has a more effecient calc. Mike
Slobey Posted November 19, 2007 Author Posted November 19, 2007 spoke too soon. If field a starts with a zero, my formula counts it as text. so field b shows 1 it field a is 01562213. Still need help Thanks
comment Posted November 19, 2007 Posted November 19, 2007 How about: Length ( YourField ) - Length ( Filter ( YourField ; "0123456789 " ) )
sbg2 Posted November 20, 2007 Posted November 20, 2007 What if the field contains a character that is not a number or or a letter? Might try... Length (Filter(Lower (MyText); "abcdefghijklmnopqrstuvwxyz"))
comment Posted November 20, 2007 Posted November 20, 2007 And what if it contains an accented or Greek letter?
Slobey Posted November 21, 2007 Author Posted November 21, 2007 I am using this to find valid PO's in my database. The PO should only contain numbers, nothing else. So if I use Comments formula and subtract the numbers then if anything is left the PO is invalid. It doesn't matter what character is left. My calc is case( Length (PO field) - Length ( Filter ( PO field; "0123456789 " ) ) > 0 ; "Invalid";"Valid") Seems to work for my purposes, or am I missing something?
comment Posted November 21, 2007 Posted November 21, 2007 Not really. Except you could make it a bit simpler: PO field = Filter ( PO field ; "0123456789 " ) The result could be a Number, formatted to show non-zeros as "Valid" and zeros as "Invalid".
Slobey Posted November 21, 2007 Author Posted November 21, 2007 But that calc would show 061b493 as 061493 and call it valid, I want to flag everything that has a non numeric character anywhere in the field as invalid.
comment Posted November 21, 2007 Posted November 21, 2007 But that calc would show 061b493 as 061493 and call it valid No, it would return 0 (False) and call it "Invalid". Mind you, the formula is the entire line. IOW, the calculation field cValidPO = PO field = Filter ( PO field ; "0123456789 " )
Recommended Posts
This topic is 6272 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