Showing posts with label beginner. Show all posts
Showing posts with label beginner. Show all posts

Thursday, March 22, 2012

Easy IF statement (Beginner)

Im not really keen on If statements, so im trying to figure out how to write an if statement in a matrix. I want it to list the values that begin with 4's as 2004 the values that start with 5's as 2005 and the values that begin with 6's as 2006. How do i do this? Whats the IF statement code, i know how to put one option. but now all.

=IIF(Fields!ICNNo.Value=Left(1),2004,) ? I know thats wrong..

Please Help.

One way you could do this is using nested IIF statements. Like this:

=iif(left(Fields!ICNNo.Value, 1) = "4", "2004",
iif(left(Fields!ICNNo.Value, 1) = "5", "2005",
iif(left(Fields!ICNNo.Value, 1) = "6", "2006", "OtherValue")))

Hope this helps.

Jarret

|||It worked!!! THANKS ALOT!!!! It worked perfectly!

Easy but Im new...

Hi All,

So I'm only a beginner at Crystal but here it goes: I am writing a report for the Helpdesk that tells them the amount of issues they need to escalate out of their group. I had to do a TrimRight({Column}20 to 35) and also added a TRIM to cut out any leading or ending spaces.

This part worked great, exactly what I needed, but now I need to match that value from the formula with a column in a database. The value gives me back a login name such as TBARLOW. I now need to match that value to the loginid column and see if it matches anything in that column.

IF {@.Trim} = {Support_Staff.Login ID} then
{Incident_Details.From Group:}

There are no errors in the formula...so basically I need it to say: take @.trim and find that value in the {Support_Staff.Login ID} field.

Any help would be great,
Thanks so much,
Timwell 2 things - do you know if {Support_Staff.Login ID} has any leading or ending spaces? As common practice (espcecially if comparing) I always use TRIM on each field. I.E.

If {@.Trim} = trim({Support_Staff.Login ID}) then ...

the second thing - and maybe this is just a typo - Is {Support_Staff.Login ID} supposed to be {Support_Staff.LoginID} or maybe {Support_Staff.Login_ID}? If you just double clicked on the field in the Report Fields, then it should be right, if you just typed it in thought there might be a problem. As far as I know, most databases don't like spaces in the field names.sql