Smart questions
Smart answers
Smart people
Join Tek-Tips Forums
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Member Login




Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips now!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

Join Tek-Tips
*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.
Jobs from Indeed

Link To This Forum!

Partner Button
Add Stickiness To Your Site By Linking To This Professionally Managed Technical Forum.
Just copy and paste the
code below into your site.

Jeremiah31 (Programmer) (OP)
14 Feb 07 14:40
Never created a "If" statement in Crystal.

Trying to count keyrec's are between 0 to 2 work days.

Should the formula be something like


Count(IIf({@WorkDays} Between 0 to 2,{iSeriesSQL_FADC_Unfinalized_Keyrec.KEYREC}))
Jeremiah31 (Programmer) (OP)
14 Feb 07 15:09
I tried using:

Iif ( Between ( {@WorkDays}, 0, 2 ), Count({iSeriesSQL_FADC_Unfinalized_Keyrec.KEYREC})


I received an error message, ")" is missing?

Two questions, What is the difference between IF and IIF?

What does ")" is missing mean?
samiam07 (TechnicalUser)
14 Feb 07 15:15
Your formula needs another ')' at the end.
Iif ( Between ( {@WorkDays}, 0, 2 ), Count({iSeriesSQL_FADC_Unfinalized_Keyrec.KEYREC}))

IIF is called an immediate if. Kind of a very basic form of if.

IF allows a more structered if statement:
If condition
Then Do_True
Else Do_False.
Jeremiah31 (Programmer) (OP)
14 Feb 07 15:20
I'm still receiving ")" is missing error message.
BobSuruncle (TechnicalUser)
14 Feb 07 16:02
Are you trying to count this for the entire report and then show it in the report footer?
If so, then try this:

If {@WorkDays} in 0 to 2 then 1 else 0

Place this formula in the details section and suppress it.
Right-click the formula and from the shortcut menu, choose Insert Summary.
Choose to place the summary in the report footer.

You could also use a Running Total field, but they're slower as they evaluate in the 2nd pass.

Bob Suruncle

lbass (TechnicalUser)
14 Feb 07 18:47
Bob's approach is more likely to give correct results, since the syntax:

if field=x then count(y) will just give you the total count for the report if the last record meets your criterion. You need to approach this by making the detail row conditional on your criterion and then insert a summary, as Bob shows.

-LB
Madawc (Programmer)
15 Feb 07 5:42
Maybe try Iif ( Between ( {@WorkDays}, 0, 2 )),

I think the problem is that you have two opening brackets for the IIF statement and only one closing.

It is also much quicker to use Running Totals, which do the work for you.  It saves programmer time, though the machine certainly has to do more work.  In context, which is more important?

As for

Quote:

What is the difference between IF and IIF?
Iif is intended to work like Visual Basic - which I'm not familiar with, I prefer to let Crystal do most of the work.

It helps to give your Crystal version - 8, 8.5, 9, 10, 11 or whatever.  Methods change between versions, and higher versions have extra options.

yinyang Madawc Williams (East Anglia, UK).  Using Windows XP & Crystal 10 yinyang

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Back To Forum

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close