Member Login

Remember Me
Forgot Password?
Join Us!

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • 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.

Count If Statement

Count If Statement

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}))

RE: Count If Statement

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?

RE: Count If Statement

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.

RE: Count If Statement

I'm still receiving ")" is missing error message.

RE: Count If Statement

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

RE: Count If Statement

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.


RE: Count If Statement

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


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

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

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!


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