Help issue with iif and basic mathematical functions

  • Now this seems simple but its driving me up the wall for something that seems so simple.

    I am attempting to preform an mathematical action on using the value from a text box in a table within an iif statement, for example

    if the value in textbox1 is numeric then display the value of textbox1 -1 in textbox2

    i have attempted the following so far

    Formula in textbox2

    =iif(isnumeric(reportitems!Textbox1.value),"Is A Number","Not A Number")

    This works correctly displaying the correct output

    =iif(isnumeric(reportitems!Textbox1.value),reportitems!Textbox1.value,"Not A Number")

    will display the value of Textbox1 if numerical otherwise will display "Not A Number"

    now this is when it errors

    =iif(isnumeric(reportitems!Textbox1.value),reportitems!Textbox1.value-1,"Not A Number")

    this displays the correct value if Textbox1 is numeric , it doesn't display "Not A Number" just shows #Error if Textbox1 is non numeric

    Is this a bug with SSRS or am i missing something obvious

    Many Thanks

  • Isnumeric() isn't perfect. You could get a positive result with a value that can't be used in mathematics. Check your data.

  • Many thanks for your reply

    The value of Textbox1 will either be "-" or numeric

    if I change the formula to read

    =iif(reportitems!Textbox1.value="-","Not A Number",reportitems!Textbox1.value-1) i still receive the same error as before. but this time in reverse it shows "Not a Number" when the value of Textbox1 is "-" and #Error for the sum if I remove the -1 then it displays correctly

     

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply