Question - Subtracting Two Fields

I have this formula in a computed numbers field called ProdLoss_1:

a:=@If(Estr_M=“”;0;Estr_M);

b:=(@If(DailyProd_1= “”;0;DailyProd_1));

a - b

It substracts the values which works fine. What I want to happen is, if DailyProd_1 is 0 then to zero out ProdLoss_1. In other words, there has to be values in both Estr_M and DailyProd_1 for the formula to work. Is this possible? I tryed :=(@If(DailyProd_1= “0”;0;DailyProd_1)), without any luck.

Subject: Question - Subtracting Two Fields

You might try (although note the potential for negative values resulting from a-b, if that’s a concern):

a:=@If(

@IsError(@TextToNumber(@Text(Estr_M))); 0;

@TextToNumber(@Text(Estr_M))

);

b:=@If(

@IsError(@TextToNumber(@Text(DailyProd_1))); 0;

@TextToNumber(@Text(DailyProd_1))

);

a - b;

Subject: RE: Question - Subtracting Two Fields

No, it’s not setting ProdLoss_1 to zero, but it will calculate with a value. Same thing.

Subject: RE: Question - Subtracting Two Fields

OK - I missed that part. In that case, I think the following would work:

a:=@If(

@IsError(@TextToNumber(@Text(Estr_M))); 0;

@TextToNumber(@Text(Estr_M))

);

b:=@If(

@IsError(@TextToNumber(@Text(DailyProd_1))); 0;

@TextToNumber(@Text(DailyProd_1))

);

REM {Before returning the difference, check if DailyProd_1 (stored in b) is zero};

@If(

b = 0;

0;

a - b

)

Subject: RE: Question - Subtracting Two Fields

That did it! Thanks Cesar and sorry about the double post.

Subject: RE: Question - Subtracting Two Fields

No, it’s not setting ProdLoss_1 to zero, but it will calculate with a value. Same thing.

Subject: Question - Subtracting Two Fields

Well, you could just check for either being blank first, set to 0 if that’s the case. or then just do the same as your current formula:

@if(Estr_M=“” | DailyProd_1=“”;@return(0);“”);

Not that elegant, but should work