Joined: 11 Jun 2013
Online Status: Offline
Posts: 17
Topic: spot whats wrong with my bit of code please?? Posted: 01 Oct 2014 at 4:45am
Hi folks
can someone let me know please what is wrong with my code below?
I trying to create a calculated field that will output a certain value based on the value of another field, so if my JobMtl.totalCost is between.01 and 50 then I was to output a value of 67 in my calculated field. etc etc
If {JobMtl1.TotalCost} > .01 and if {JobMtl1.TotalCost} < 50 then 67 ELSE
If {JobMtl1.TotalCost} > 50.01 and if {JobMtl1.TotalCost} < 75 then 50 ELSE
If {JobMtl1.TotalCost} > 75.01 and if {JobMtl1.TotalCost} < 100 then 43 ELSE
If {JobMtl1.TotalCost} > 100.01 and if {JobMtl1.TotalCost} < 125 then 38 ELSE
If {JobMtl1.TotalCost} > 125.01 then 0
When I try to save code I'm using above it tells me the keyword Then is missing.
you only need to write the first if for each line, ie IF {JobMtl1.TotalCost}> .01 and {JobMtl1.TotalCost} < 50 then 67 ELSE
Though a better way to write it might be:
If {JobMtl1.TotalCost} in .01 to 50 then 67 ELSE If {JobMtl1.TotalCost} in 50.01 to 75 then 50 ELSE If {JobMtl1.TotalCost} in 75.01 to 100 then 43 ELSE If {JobMtl1.TotalCost} in 100.01 to 125 then 38 ELSE 0
Joined: 20 Nov 2006
Online Status: Offline
Posts: 3702
Posted: 02 Oct 2014 at 4:56am
For future reference, in your original formula, you just need "and", not "and if". It was this second "if" in each line that was causing the error. The correct version of the formula is this:
If {JobMtl1.TotalCost} > .01 and {JobMtl1.TotalCost} < 50 then 67 ELSE
If {JobMtl1.TotalCost} > 50.01 and {JobMtl1.TotalCost} < 75 then 50 ELSE
If {JobMtl1.TotalCost} > 75.01 and {JobMtl1.TotalCost} < 100 then 43 ELSE
If {JobMtl1.TotalCost} > 100.01 and {JobMtl1.TotalCost} < 125 then 38 ELSE
If {JobMtl1.TotalCost} > 125.01 then 0
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum