Calculated Field Syntax Help!

Hi All!

I am trying to create a calculated field to determine estimated cost per job based on the resource or resource group assigned. I believe I am on the right track with my calculated field but I am getting the following syntax error. Could someone take a look and help me resolve this? Also can anyone help me understand what the different color coding means within the calculation?

Incorrect Syntax near the keyword ‘else’

sum((case when (JobOpDtl.ResourceGrpID) is null then (( JobOpDtl.EstProdHours* Resource.ProdLabRate )+(Resource.ProdBurRate * JobOpDtl.EstProdHours )+(JobOpDtl.EstSetHours * Resource.SetupLabRate)+(Resource.SetupBurRateJobOpDtl.EstSetHours) else (( JobOpDtl.EstProdHours ResourceGroup.ProdLabRate )+(ResourceGroup.ProdBurRate * JobOpDtl.EstProdHours )+(JobOpDtl.EstSetHours * ResourceGroup.SetupLabRate)+(ResourceGroup.SetupBurRate * JobOpDtl.EstSetHours) end))

I do have a multiplication added between else (( JobOpDtl.EstProdHours * ResourceGroup.ProdLabRate ) but for some reason when it is copied into this forum it is not showing.

Hey @khagedorn It looks like you’re also missing an operator here.

image

Try this

SUM(CASE 
    WHEN (jobopdtl.resourcegrpid ) IS NULL THEN 
  ( jobopdtl.estprodhours * Resource.ProdLabRate ) + (resource.prodburrate * jobopdtl.estprodhours ) + (jobopdtl.estsethours * Resource.SetupLabRate) + (resource.setupburrate * jobopdtl.estsethours)
ELSE 
  ( jobopdtl.estprodhours * resourcegroup.prodlabrate )+(resourcegroup.prodburrate * jobopdtl.estprodhours )+(jobopdtl.estsethours * resourcegroup.setuplabrate)+(resourcegroup.setupburrate * jobopdtl.estsethours) 
END)

That worked thank you!!

1 Like