Report Design
 Crystal Reports Forum : Crystal Reports 9 through 2022 : Report Design
Message Icon Topic: Problem w/formula. Error: "A string is req here" Post Reply Post New Topic
Author Message
dawnh44
Groupie
Groupie


Joined: 25 Sep 2011
Online Status: Offline
Posts: 79
Quote dawnh44 Replybullet Topic: Problem w/formula. Error: "A string is req here"
     Posted: 14 Feb 2012 at 4:39am
Hello everyone,
 
I have the following formula:
 
if isnull({member_count_by_parent.EE_Total}) then 'Cancelled' else (DistinctCount ({S_SRV_REQ.SR_NUM}, {S_ORG_EXT_1.NAME})/{member_count_by_parent.EE_Total}*100)
 
I keep receiving the error message stating, "A string is required here."  Does anyone have any ideas?
 
Thank you.
IP IP Logged
rkrowland
Senior Member
Senior Member
Avatar

Joined: 20 Dec 2011
Location: England
Online Status: Offline
Posts: 259
Quote rkrowland Replybullet Posted: 14 Feb 2012 at 4:42am

A field can only contain 1 datatype, eg a number or a string - your if statement could return a string or a number hence the error.

 
You either need to make the "Cancelled" a number (0 for example) or the else statement a string - you can do that by enclosing it in the totext() function. eg;
 
 
if isnull({member_count_by_parent.EE_Total})
then
'Cancelled'
else
totext(DistinctCount ({S_SRV_REQ.SR_NUM}, {S_ORG_EXT_1.NAME})/{member_count_by_parent.EE_Total}*100)
 
 
Regards,
Ryan.


Edited by rkrowland - 14 Feb 2012 at 4:44am
IP IP Logged
dawnh44
Groupie
Groupie


Joined: 25 Sep 2011
Online Status: Offline
Posts: 79
Quote dawnh44 Replybullet Posted: 14 Feb 2012 at 8:24am
YOU'RE A GENIOUS!!!!  Thank you.
 
I have another question.  Is there a way to add the % sign to the formula?  It won't allow me to do this from the menu bar. 
 
IP IP Logged
kostya1122
Senior Member
Senior Member
Avatar

Joined: 13 Jun 2011
Online Status: Offline
Posts: 475
Quote kostya1122 Replybullet Posted: 14 Feb 2012 at 9:19am
try this

if isnull({member_count_by_parent.EE_Total})
then
'Cancelled'
else
totext(DistinctCount ({S_SRV_REQ.SR_NUM}, {S_ORG_EXT_1.NAME})/{member_count_by_parent.EE_Total}*100)+"%"
IP IP Logged
dawnh44
Groupie
Groupie


Joined: 25 Sep 2011
Online Status: Offline
Posts: 79
Quote dawnh44 Replybullet Posted: 15 Feb 2012 at 2:58am
Thank you so much.  It worked!!!!!  Big%20smile
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