Technical Questions
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Technical Questions
Message Icon Topic: Formula cap Post Reply Post New Topic
Author Message
KevV
Senior Member
Senior Member


Joined: 19 May 2011
Online Status: Offline
Posts: 106
Quote KevV Replybullet Topic: Formula cap
     Posted: 19 May 2011 at 5:16am
I have a formula that counts if a field meets a criteria but if it goes over 100 I need it to stop counting and just show 100.
 
Thanks
KevV
IP IP Logged
Keikoku
Senior Member
Senior Member


Joined: 01 Dec 2010
Online Status: Offline
Posts: 386
Quote Keikoku Replybullet Posted: 19 May 2011 at 5:34am
If what goes over 100?
IP IP Logged
KevV
Senior Member
Senior Member


Joined: 19 May 2011
Online Status: Offline
Posts: 106
Quote KevV Replybullet Posted: 19 May 2011 at 6:43am
If the calculation. so for example if I count the number of times a word shows up in a column, I want it to show the total but if it shows up 500 times I just want it to say 100
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 19 May 2011 at 7:23am
if it is simply for display purposes and not additianl calculations you can just use the 'Display string' in the common tab of the foramt editor for the field
 
if currentfieldvalue>100 then '100' else totext(currentfieldvalue,0,'')


Edited by DBlank - 19 May 2011 at 7:23am
IP IP Logged
KevV
Senior Member
Senior Member


Joined: 19 May 2011
Online Status: Offline
Posts: 106
Quote KevV Replybullet Posted: 19 May 2011 at 7:50am
It worked great when I run the report in crystal but the company is using a program called i-net server for end users to access and when I run it thru that it shows the original number.
 
Thanks
Kev


Edited by KevV - 19 May 2011 at 7:51am
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 19 May 2011 at 8:30am
probably need to go with a 2 part  if-then statements in a shared variable
not my forte but something like
 
whileprintingrecords;
shared numbervar x;
x := x + if x < 20 and other criteria here then 1;
IP IP Logged
KevV
Senior Member
Senior Member


Joined: 19 May 2011
Online Status: Offline
Posts: 106
Quote KevV Replybullet Posted: 20 May 2011 at 4:01am
I am new to crystal but I am wondering why you have the <20 or should that be 100 and I am also not sure what the other criteria would be. I have tried numbers and statements but i just errors saying it is looking for numbers or boolean.
IP IP Logged
DBlank
Moderator
Moderator


Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
Quote DBlank Replybullet Posted: 20 May 2011 at 7:10am
Sorry Kev,
You are correct it should have been 100 (I pasted a test formula that I used 20 on)
The 'Other Criteria here' is for you to add your other inclusion criteria (like the word that you are counting in the column). It needs to be a boolean (True/False) result like
and table.field="Word"
IP IP Logged
KevV
Senior Member
Senior Member


Joined: 19 May 2011
Online Status: Offline
Posts: 106
Quote KevV Replybullet Posted: 20 May 2011 at 7:46am
tried it but it gives error saying remaing text does not appear to be part of the formula. Here is my formula.
 
x := x + if x < 100 and {@New Item}="new" then 1;
 
 


Edited by KevV - 20 May 2011 at 7:48am
IP IP Logged
Emir_W
Senior Member
Senior Member
Avatar

Joined: 25 Apr 2010
Online Status: Offline
Posts: 228
Quote Emir_W Replybullet Posted: 21 May 2011 at 10:37pm
Kev,

I think the condition should be same type.

in your formula the type is Numeric and String (if x<100 and {@newite}="new").

you need to make it same type (as Numeric or as String) for both.


hope it help.

Emir W
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