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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

frequency of "X" in field 1

Status
Not open for further replies.

MHPGuy

IS-IT--Management
Mar 14, 2002
143
US
In my detail section I have a field that has what is basically a concatenation of several other objects. I'm looking for a way to count the number of times a value (X)appears in the field.

Example:

Field Value: XXXYZUYYCX

formula result: 4 (because the value X appears in the field 4 times...

Any ideas?
 
Create a formula:

numbervar i;
numbervar j := len({table.field});
numbervar k := 0;

for i := 1 to j do(
if {table.field} = "X" then
k := k + 1
);
k

-LB
 
I can't seem to get it working... Here's what I changed it to:

numbervar i;
numbervar j := len({@age compiler});
numbervar k := 0;

for i := 1 to j do(
if {@age compiler} = "60-64" then
k := k + 1
);
k

The possible values in the field (which may have multiples of each of these values) are:

"1-4"
"5-18"
"19-24"
"25-29"
"30-34"
"35-39"
"40-44"
"45-49"
"50-54"
"55-59"
"60-64"
"65+"

So, it's possible to see the field read:

1-5,25-29,60-64,60-64

I'm looking for something to return the # of times the value 60-64 appears in the field (in this case, twice).

Am I not understanding your example, or not explaining myself well? I appreaciate any help you can give...

Michael Phipps
Technical Business Analyst
Mercy Health Plans
 
This is somewhat different than the originally posed problem--one reason not to oversimplify.

Change the formula to:

stringvar array x := split({@age compiler},",");
numbervar i;
numbervar j := ubound(x);
numbervar k := 0;

for i := 1 to j do(
if x = "60-64" then
k := k + 1
);
k

-LB
 
you are a goddess among mortals. Thank you!

Michael Phipps
Technical Business Analyst
Mercy Health Plans
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top