Crystal formula result question

Posted on 2011-09-16
Last Modified: 2012-08-13
This formula returns 75.00 everytime. The field HourlyRate defaults to 75.00. Then I check the location and employee type to determine if the hourly Rate should be chaned to 65.00 or 25.00.
What's the correct way to do this? I've been trying various things like instr but am not having luck. I need a formula that returns a number. If I remove the last line the formula returns true or false. Thanks.

Global NumberVar HourlyRate;
HourlyRate := 75.00;

If {Projects.Location} like "Apples" then
    HourlyRate := 25.00;

If {Projects.Employee Type} like "Oranges" then
      HourlyRate = 65.00;
Question by:MidWestGirl
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
  • 2
LVL 100

Expert Comment

ID: 36551375
Try this
Global NumberVar HourlyRate;
HourlyRate := 75.00;

If {Projects.Location} like "*Apples*" then
    HourlyRate := 25.00;

If {Projects.Employee Type} like "*Oranges*" then
      HourlyRate = 65.00;


Author Comment

ID: 36551407
H Mlmcc. The formula you suggested look like the one I tried. I'm not seeing the difference
between yours and the one I posted.

Author Comment

ID: 36551423
I did add the WhilePrintingRecords but it still comes out to 75.00 everytime.
[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

LVL 100

Accepted Solution

mlmcc earned 300 total points
ID: 36551686
I added * * around your text.  Like needs them to do a wildcard search.

LVL 35

Assisted Solution

James0628 earned 200 total points
ID: 36553875
mlmcc's right about the "*"s.  You need those for LIKE.  Another problem is this line near the end of your formula:

      HourlyRate = 65.00;

 That should be:

      HourlyRate := 65.00;

 := assigns a value to a variable.  = compares values.  It's an easy mistake to make, and to miss.

 So, if "Employee Type" contained Oranges, you were just comparing HourlyRate to 65, instead of setting it to 65.  That's why you got True or False when you removed the last line.  Actually, it should have always returned False.

 If you're still not getting the correct results after changing that, then there's something else going on.  Presumably "Apples" and "Oranges" are just example values.  If your real values are more complicated, maybe your tests aren't working.  Case might also be an issue (depending on your settings, "apples" may or may not match "*Apples*").  And if any of those fields could be null, that could be a problem.


Author Closing Comment

ID: 36563182
Thanks! the 2 suggestions given to me worked.

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Exporting Crystal report withh dynamic image in C# 5 101
Conditional Page Breaks Based On Grouping 1 46
Crystal Reports 2013 25 78
Sum Before Standard Deviation 2 37
Crystal Reports: 5 Tests for Top Performance It is complete, your masterpiece report.  Not only does it meet your customer’s expectations, it blows them out the water, all they want is beautifully summarised and displayed in a myriad of ways. …
I hate sub reports and always consider them the last resort in any reporting solution.  The negative effect on performance and maintainability is just not worth the easy ride they give the report writer.  Nine times out of ten reporting requirements…
Nobody understands Phishing better than an anti-spam company. That’s why we are providing Phishing Awareness Training to our customers. According to a report by Verizon, only 3% of targeted users report malicious emails to management. With compan…
In an interesting question ( here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question