# Coding

• ### Question

• I can't seem to get an expression to divide correctly.

My code is:

=(Sum(IIF(Asc(Fields!SOP_Type.Value) = 82,(-Fields!Unit_Price.Value),(Fields!Unit_Price.Value)))) / (Count(Fields!SOP_Type.Value))-((Count(IIF(Asc(Fields!SOP_Type.Value) = 82,(Fields!SOP_Type.Value),Nothing)))*2)

Basically the first part gives me a number, and in a box by itself works correctly, giving me the number 270.7. The second part correctly gives me another number, 54, and it works by itself in a box as well. I have gone through and made sure that both these number are correct. The problem i'm having is that when I put both of these expressions into a single text box and divide them I get the wrong quotient.

Any help is appreciated, thank you.

Tuesday, August 30, 2016 10:06 PM

• Hi GraydonC,

=(Sum(IIF(Asc(Fields!SOP_Type.Value) = 82,(-Fields!Unit_Price.Value),(Fields!Unit_Price.Value)))) /
( (Count(Fields!SOP_Type.Value))-((Count(IIF(Asc(Fields!SOP_Type.Value) = 82,(Fields!SOP_Type.Value),Nothing)))*2) )

Because of the loss of this parenthesis, the original expression calculate divide, then subtraction which returned the wrong result.

Best regards,
Yuliana Gu

• Marked as answer by Thursday, September 1, 2016 12:13 PM
Wednesday, August 31, 2016 5:29 AM

### All replies

• Hi GraydonC,

=(Sum(IIF(Asc(Fields!SOP_Type.Value) = 82,(-Fields!Unit_Price.Value),(Fields!Unit_Price.Value)))) /
( (Count(Fields!SOP_Type.Value))-((Count(IIF(Asc(Fields!SOP_Type.Value) = 82,(Fields!SOP_Type.Value),Nothing)))*2) )

Because of the loss of this parenthesis, the original expression calculate divide, then subtraction which returned the wrong result.