Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using nested if then statements to retreive user pay rate

Status
Not open for further replies.
Apr 15, 2005
12
US
The purpose of the report is to show employee wages, both regular and overtime by property, then further broken down by department. This formula (@Job Rate) is used to calc and display the bill rate, which is then multiplied by the hours to get the amount (@amount). It asks what the {EPayHistDetail.detcode} is (1 = regular or 2 = overtime), then decides which payrate to use based on the {EPayHistDetail.jobcode}, looking at
the user defined rate fields {EInfo.user1,2,3, or 4}. If it is overtime {EPayHistDetail.detcode} = "2" then it is *1.5. The problem I am having is that most of the employees that show up only show overtime "({EPayHistDetail.detCode}) = "2"",
and not regular wages.
This only happens for employees with{EPayHistDetail.jobCode}= "1" for both detCodes. It seems like the first line of the code that checks for jobcode = "1" is not executing. Is there a better way to write this code, or is there some syntax wrong here? Thanks for the help.

Code:
If Left({EPayHistDetail.detCode},1) = "1" then
If Left({EPayHistDetail.jobCode},1) = "1" then tonumber({EInfo.user1})
else If Left({EPayHistDetail.jobCode},1) = "2" then tonumber({EInfo.user2})
else if Left({EPayHistDetail.jobCode},1) = "3" then tonumber ({EInfo.user3})
else if Left({EPayHistDetail.jobCode},1) = "4" then tonumber ({EInfo.user4})

else

If Left({EPayHistDetail.detCode},1) = "2" then
if Left({EPayHistDetail.jobCode},1) = "1" then tonumber({EInfo.user1})*1.5
else if Left({EPayHistDetail.jobCode},1) = "2" then tonumber({EInfo.user2})*1.5
else if Left({EPayHistDetail.jobCode},1) = "3" then tonumber ({EInfo.user3})*1.5
else if Left({EPayHistDetail.jobCode},1) = "4" then tonumber ({EInfo.user4})*1.5


 
Try using parentheses around your inner If Then Else

Code:
If Left({EPayHistDetail.detCode},1) = "1" then
   ( If Left({EPayHistDetail.jobCode},1) = "1" then tonumber({EInfo.user1}) 
     else If Left({EPayHistDetail.jobCode},1) = "2" then tonumber({EInfo.user2}) 
     else if Left({EPayHistDetail.jobCode},1) = "3" then tonumber ({EInfo.user3}) 
     else if Left({EPayHistDetail.jobCode},1) = "4" then tonumber ({EInfo.user4})  )

else

If Left({EPayHistDetail.detCode},1) = "2" then   
   ( if Left({EPayHistDetail.jobCode},1) = "1" then tonumber({EInfo.user1})*1.5 
     else if Left({EPayHistDetail.jobCode},1) = "2" then tonumber({EInfo.user2})*1.5 
     else if Left({EPayHistDetail.jobCode},1) = "3" then tonumber ({EInfo.user3})*1.5 
     else if Left({EPayHistDetail.jobCode},1) = "4" then tonumber ({EInfo.user4})*1.5 )


Bob Suruncle
 
Thanks but the formula produced the same result. It was a great idea though, it makes alot of sense that these should be separated by parenthesis. Thanks!
 
I'd guess that your data isn't returning what you expect as either formula looks OK at first glance. You might further qualify with an additional else clause as in:

If Left({EPayHistDetail.detCode},1) = "1" then
( If Left({EPayHistDetail.jobCode},1) = "1" then tonumber({EInfo.user1})
else If Left({EPayHistDetail.jobCode},1) = "2" then tonumber({EInfo.user2})
else if Left({EPayHistDetail.jobCode},1) = "3" then tonumber ({EInfo.user3})
else if Left({EPayHistDetail.jobCode},1) = "4" then tonumber ({EInfo.user4})
else -9999)

else

If Left({EPayHistDetail.detCode},1) = "2" then
( if Left({EPayHistDetail.jobCode},1) = "1" then tonumber({EInfo.user1})*1.5
else if Left({EPayHistDetail.jobCode},1) = "2" then tonumber({EInfo.user2})*1.5
else if Left({EPayHistDetail.jobCode},1) = "3" then tonumber ({EInfo.user3})*1.5
else if Left({EPayHistDetail.jobCode},1) = "4" then tonumber ({EInfo.user4})*1.5
else -1111)
else
-4444

Now you will have a RESULT in every instance and can better analyze what's happening.

Also check you record selection formula(s).

-k
 
The formula did help me figure out what was actually printing in the details section. But when I changed one of the record selection formulas it worked perfectly! thanks.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top