none
Coding RRS feed

  • 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

Answers

  • Hi GraydonC,

    In your scenario, please add a parenthesis in the outermost layer for second part, modify your expression like:
    =(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.

    If you have any question, please feel free to ask.

    Best regards,
    Yuliana Gu

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

All replies

  • Hi GraydonC,

    In your scenario, please add a parenthesis in the outermost layer for second part, modify your expression like:
    =(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.

    If you have any question, please feel free to ask.

    Best regards,
    Yuliana Gu

    • Marked as answer by GraydonC Thursday, September 1, 2016 12:13 PM
    Wednesday, August 31, 2016 5:29 AM
  • Thanks so much! I knew it had to be something simple like that, but I ran out of time that day ha. Staring at this and a bunch of other ones all day makes me lose track of the needed parenthesis.

    Thanks again Yuliana, and have a good day.

    Thursday, September 1, 2016 12:12 PM