Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Count of certain characters in a field

Status
Not open for further replies.

acantho

Technical User
Sep 12, 2006
10
CA
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
 
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
 
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
 
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....
 
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.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top