• Status: Solved
• Priority: Medium
• Security: Public
• Views: 1540

# 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
0
dking_wri
1 Solution

Commented:
Would this work;

If {field}="Y" Then
Sum({amount})
Else
0;
0

Commented:
Create a formula with

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

You should be able to use Sum on that formula.

James
0

Commented:
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.
0

Author Commented:
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)
0

Commented:
Two formulas and two summaries don't seem like that big a deal, and I'm not sure exactly what you're trying to do, but you could also consider using running totals.  Maybe they'd better suit your needs.  For example, for your original problem, you could create a running total on {amount} and set it to evaluate when {field} = "Y".

James
0

Author Commented:
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!
0

Commented:
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
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.