| Author |
Message |
Sebastian1999
Newbie
Joined: 28 Nov 2012
Online Status: Offline
Posts: 5
|

Topic: Please help. A string is required here. Posted: 28 Nov 2012 at 2:34pm |
I'm fairly new to Crystal Reports and encountered an error doing a formula.
The error is "A string is required here". A copy of the formula causing the error is below.
Else
if {category1} = "555" then Sum ({category2}, {category3})/278 * 24
That final statement in my formula seems off, but I can't put my finger on the problem.
|
IP Logged |
|
|
|
Sastry
Moderator
Joined: 16 Jul 2012
Online Status: Offline
Posts: 537
|

Posted: 28 Nov 2012 at 6:10pm |
Hi Do you have a group on {category3} ? if not you will have to calculate separately then add them like : Numbervar x; if {category1} = "555" then x:=Sum ({category2})/278 * 24 + Sum({category3})/278 * 24;
|
|
Thanks,
Sastry
|
IP Logged |
|
Sebastian1999
Newbie
Joined: 28 Nov 2012
Online Status: Offline
Posts: 5
|

Posted: 28 Nov 2012 at 6:41pm |
What do you mean by group? Basically, it's if it equals 555 then it's going to sum up the total of two fields and then apply dividing 278 and multiplying by 24. I'm just creating this formula to parse data that will be displayed on a report based the on values it finds in the database. Hope that's not too confusing.
|
IP Logged |
|
Sastry
Moderator
Joined: 16 Jul 2012
Online Status: Offline
Posts: 537
|

Posted: 28 Nov 2012 at 8:38pm |
In Crystal, it is not possible to sum up values using sum(value1,value2,value3) You need to sum the fields independetly i.e. sum(value1)+Sum(value2)+sum(Value3) Hope the above helps you
|
|
Thanks,
Sastry
|
IP Logged |
|
Sebastian1999
Newbie
Joined: 28 Nov 2012
Online Status: Offline
Posts: 5
|

Posted: 29 Nov 2012 at 4:51am |
Can it just be done like this?
if {category1} = "555" then Sum ({category2})/278 * 24 + Sum({category3})/278 * 24
or does the numvar need to be used?
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|

Posted: 29 Nov 2012 at 5:02am |
I think you just want
if {category1} = "555" then ((({category2}+ {category3})/278) * 24)
|
IP Logged |
|
Sebastian1999
Newbie
Joined: 28 Nov 2012
Online Status: Offline
Posts: 5
|

Posted: 29 Nov 2012 at 5:04am |
Don't need the sum then? I need to calculate the two values then divide and multiply by 24.
thanks
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|

Posted: 29 Nov 2012 at 5:14am |
the SUM is used to sum multiple rows of data, either at a group level or a entire report level.
you can just add two field together on one line using "+"
if you need to see an aggragate amount at the report level the create a formual to add the two fields togther at the row level
//1_2_combined
if {category1} = "555" then ({category2}+ {category3})
then sum this. This example is for the entire report not a group
(((SUM(@1_2_combined)) / 278) * 24)
|
IP Logged |
|
Sebastian1999
Newbie
Joined: 28 Nov 2012
Online Status: Offline
Posts: 5
|

Posted: 29 Nov 2012 at 7:27am |
Here is a bette explantion of my issue (hopefully).
The formula created using the formula editior and then it will be added to the report via the insert fields (formula tab) option.
Basically, the formula is going to pulling existing data from the report and applying the calcuation to it. I hope that explains it better.
So the report heading is kind of like this...
category3 category1 category2
(this is unique) 555 (example) (dollar amount)
Formula will look at the value in category1. If it equals 555, then its going to take the amount in category 2 and apply the calculation to it.
|
IP Logged |
|
DBlank
Moderator
Joined: 19 Dec 2008
Online Status: Offline
Posts: 9053
|

Posted: 29 Nov 2012 at 8:50am |
so I think you want a sum of dollar amount for each person(category3) when the row is identified as category1= 555.
you can use running totals for this (or shared variables)
Name=whatever
field to summarize=category2
type of summary=sum
evaluate=use a formula
{category1} = "555"
reset=on change of field (cat3) if you want to reset the sum for each person or never if you want a sum across people
plce it in RT in the detial section or footers. RTs do not work in headers
|
IP Logged |
|
|
|