×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Count of certain characters in a field

Count of certain characters in a field

Count of certain characters in a field

(OP)
Is there a way to count the number of times a certain character, series of characters, or number show up in a field on the same record?

example

field1 = 1234 123 4321 anna 1324 1234 1 2 3 4

is there a way to determine the following
how many times 1234 shows up not ignoring spaces
should return 2
how many times the character 1 shows up total
should return 6
how many times 2 shows up not ignoring spaces
should return 1

RE: Count of certain characters in a field

Make a global text field to hold the searchstring (checkText_g).

Make a calculation field, unstored, result number along these lines:

PatternCount( yourTextField; checkText_g).

If you're in FM 7/8 you make a script and using the script parameter function to make everything dynamic.

Remember, for not ignoring spaces, the space character should be used in the checkText_g field....

HTH

RE: Count of certain characters in a field

(OP)
Okay,

I knew about that function but wasn't too sure about spaces.

So in
1 1 1 1 1 2 11

If I wanted to find the amount of times the number "1" showed up ignoring any spaces it would be
PatternCount( yourTextField; "1")
This would return 7?

and if I wanted to find the amount of time the number "1" showed up not ignoring spaces it would be
PatternCount( yourTextField; "1 ")
This would return 5?
Or would it return 6  due to the "11"?

That's the question I have...
I mean I guess I could just try it and see :P
Talk about being lazy eh? hahahahaha

RE: Count of certain characters in a field

It's best not to hard code the search string in your calc field.
This will make your file mor dynamic.

And yes, you will have totry it out....

RE: Count of certain characters in a field

(OP)
Unfortunately it needs to be hard coded as it's part of a calculation field that is, believe it or not, based on static values brought over through a lookup.

I've been using a weird calculation so far but this will make it easier for the end user to modify rather then having me come in and change things around in the calcs each time a new item is added.

I just wasn't sure if it would work the way I needed it to but you have reasured me.

thanks.

Unfortunately, last night, I was given some information that means the work I started, just got 20 times harder and longer.  Oh the life.

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close