×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Log In

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!

*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.

Students Click Here

If Then...Decode Function

If Then...Decode Function

If Then...Decode Function

(OP)
Does anyone know how to create the if then function in a derived field? I need to create a field that calculates annualized earnings.  I keep trying to create the field using the decode function but it isn't working properly.  

If PayFreq = B and RateType = S
 Then Rate1* 26
Else if
If PayFreq = W and RateType = H
Then (Rate1* 40)*52

thanks

RE: If Then...Decode Function

This should work



Decode(PayFreq,
   'B',Decode(RateType,'S',(Rate1 * 26),0),
   'W',Decode(RateType,'H',((Rate1 * 40) * 52),0),
    0)

CharlesCook.com
ADP - PeopleSoft - SAP
ReportSmith - Crystal Reports - SQR - Query - Access
Reporting - Interfaces - Data Mining

RE: If Then...Decode Function

(OP)
Thanks but I forgot a part, we have both Salaried employees paid weekly & biweekly plus straight hourly weekly.  I need to include all 3 variables.  Like the following but it doesn't work.  Any suggestions.  

Decode("REPORTS"."V_EMPLOYEE"."PAYFRQ",
   'W',Decode("REPORTS"."V_EMPLOYEE"."RATETYPE",'S',( "REPORTS"."V_EMPLOYEE"."RATE1AMT" * 52),0),
    'B',Decode("REPORTS"."V_EMPLOYEE"."RATETYPE",'S',( "REPORTS"."V_EMPLOYEE"."RATE1AMT"* 26),0),
   'W',Decode("REPORTS"."V_EMPLOYEE"."RATETYPE",'H',(( "REPORTS"."V_EMPLOYEE"."RATE1AMT" * 40) * 52),0),
    0)

RE: If Then...Decode Function

The decode would never get to the second "W" code.

This should work



Decode("REPORTS"."V_EMPLOYEE"."PAYFRQ",
    'B',Decode("REPORTS"."V_EMPLOYEE"."RATETYPE",'S',("REPORTS"."V_EMPLOYEE"."RATE1AMT" * 26),0),
    'W',Decode("REPORTS"."V_EMPLOYEE"."RATETYPE",
             'S',("REPORTS"."V_EMPLOYEE"."RATE1AMT" * 52),
             'H',(("REPORTS"."V_EMPLOYEE"."RATE1AMT" * 40) * 52),
              0),
    0)

CharlesCook.com
ADP - PeopleSoft - SAP
ReportSmith - Crystal Reports - SQR - Query - Access
Reporting - Interfaces - Data Mining

RE: If Then...Decode Function

(OP)
Your right.  The decode wasn't going to the second W.  I will try this thanks and let you know.

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! Already a Member? Login


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