6 Replies Latest reply: May 15, 2014 9:54 AM by pth3x _

# simple subtraction

If an employee is in the salaried paygroup and has a time code of PT1, I want the time code hours to be subtracted from the standard hours to come up with the worked hours.

I named a calculated field Worked Hours and put in the following equation, but it doesn't cause the time code hours to be subtracted from the standard hours.

Why?

IF(PAYGROUP="SAL" .And. TIMECODE="PT1",(STDHRS-TIMECODEHOURS),TIMECODEHOURS)

Thanks!

• ###### simple subtraction

Hi pth3x and welcome to the forum.

Can you tell us what result your formula gives you?

Grant

• ###### simple subtraction

Pth3x

Like Grant I am wondering what you see.

If either field is null, you will get a null result. (Similar to using @N/A in Excel)

smile.gif[/img]

• ###### simple subtraction

Hi Bruce & Grant,

Yes, the result is null.

This confuses me because STDHRS has a numeric value of 40 in the cell and TIMECODEHRS has a numeric value of 8 in the cell.

This makes me think neither field is null, since there is an 8 in one and a 40 in the other.

But perhaps there is something wrong with that reasoning.

I thought the formula would give me a result of 40-8=32.

I can't figure out why it gives me a null value.

Thank you,

patrick

• ###### simple subtraction

When I sent that reply a moment ago, I was looking at the wrong column.

The equation doesn't give me a null result, but it doesn't give me the result I want.

The formula:

IF(PAYGROUP="SAL" .And. TIMECODE="PT1",(STDHRS-TIMECODEHOURS),TIMECODEHOURS)

where the STDHRS=40 and TIMECODEHOURS=10

gives me a result of 10.

I think the result should be 30, because 40-10=30.

I apologize for the error in my previous email.

• ###### simple subtraction

Ptx

The formula looks correct, but something is off.

Can you look at the formula in the test box? Use a few numbers and see what the result is.

By your output I suspect that STDHOURS is showing 0 somehow. Is SDTHOURS a calculated field, or a number off the report?

• ###### simple subtraction

Hi Bruce,

Thank you for verifying that the formula was correct, because that made me look elsewhere

Indeed the trap I'd created for the TIMECODE was one space too large on the left, which put in a leading space.

Once I edited the trap and removed the space, it does the subtraction fine.

I appreciate you assistance!

patrick