Need help with syntax in calculated field

I am not great at writing code so I am running into an issue but I know what I want to do just can’t execute properly.

I want to take find actual PPH based on LaborDtl.LaborQty and LaborDtl.LaborHrs. Sometimes these are both 0 when having to report multiple types of scrap which I believe is what is causing my BAQ to give me errors since dividing by 0 and all that. So I need help writing a statement IF laborhrs or LaborQty = 0 then display ‘0’ ELSE LaborQty / LaborHrs.

Or something similar to that…Any help would be appreciated.

For quick and dirty outputs, I just add a tiny amount to the denominator just to avoid div0 errors.
Hrs / (Qty + 0.0001).

Otherwise, yes, you have to use some kind of IF or CASE statement. Are you building this in a BAQ, SSRS, or customization? Each one has their own little syntax.

iif(LaborDtl.LaborHrs > 0, iif(LaborDtl.LaborQty > 0, LaborDtl.LaborQty/ LaborDtl.LaborHrs, 0), 0)

I do this sometimes when it really doesn’t matter about the low values. Just adding .001 at least lets the calculation complete without error.

This is actually a good idea and probably would have been the easier solution. I will keep that in mind! Thank you for your help the code worked perfectly.

I am currently building this in a BAQ. Nate provided code that worked for me. Your idea on the adding that tiny amount would have been the simpler solution I think. I will keep it in mind for next time.