Link to home
Start Free TrialLog in
Avatar of dking_wri
dking_wri

asked on

How can I get around the "A field is required here" in Crystal XI

For flexibility I'm trying to include an If Then Else statement inside a sum() function but I'm getting the error message: "A field is required here". Any tricks on how I can get around this? Sometimes I use totext() or tonumber() to get around similar error messages.

Here is my example:
sum (
if {field} = "Y"
then {amount}
else 0
        )

Thanks!
David
Avatar of ansvarit
ansvarit

Would this work;

If {field}="Y" Then
  Sum({amount})
Else
  0;
Avatar of James0628
Create a formula with

if {field} = "Y"
then {amount}
else 0


 You should be able to use Sum on that formula.

 James
yeah, james's solution is correct. Make sure that you put it in the detail line so that you can right click and insert summary.
Avatar of dking_wri

ASKER

Thanks for your comments. I was trying to avoid using a summary object and thought that there might be a trick to get around this in a single formula. I need to create a second formula that tests for a "N" value and thought I could just duplicate and modify the formula as opposed to creating 4 objects ( two formulas and two summaries)
ASKER CERTIFIED SOLUTION
Avatar of James0628
James0628

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Hello James,
You are correct that two formulas and two summaries is not a big deal but I need to then replicate this process across 50 different objects which creates a 100 new formulas in my report. I was trying to minimize this number. I'll also try the running totals as you suggested. Thanks for your help!
I thought there might be more to it than just 2 formulas and summaries, but, of course, had no way to be sure.  I'm afraid you may just be stuck with having to create a lot of different objects.  FWIW, you can do things like copy the contents of one formula and paste them into another, which may help a little.

 James