Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Counting strings row wise?? Post Reply Post New Topic
Author Message
Gurojee
Newbie
Newbie


Joined: 23 Feb 2009
Location: India
Online Status: Offline
Posts: 6
Quote Gurojee Replybullet Topic: Counting strings row wise??
     Posted: 10 Aug 2010 at 4:44pm
Hi,
I have report which has similar scenario as below. I go “f” in field and want to count number of “f” occurs in each row. If any row does not contain “f” then it should return 0 (zero). If the row contains “f” then I should count them.
Any ideas please, how to count the numbers of “f” in each row through crystal report formula?

ID    A     B    C   D   Total
1             f          f       2
2      f                         1
3      f      f     f    f       4
4                                0
IP IP Logged
lockwelle
Moderator
Moderator


Joined: 21 Dec 2007
Online Status: Offline
Posts: 4374
Quote lockwelle Replybullet Posted: 11 Aug 2010 at 3:14am
local numbervar iNext := 0;
local numbervar iCount :=0;
do (
  iNext := instr(iNext + 1, {table.field}, "f");  //this is case sensitive
  if iNext > 0 then iCount := iCount + 1;
)
loop while iNext > 0;
iCount
 
HTH
IP IP Logged
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum