Strings, Splitting, and Numerics

I am having problems splitting numeric values in Reporting Services 2005. I have a string such as “2, 3, 4, A”. When I run the following statement I receive an error:

IIF(IsNumeric(Split(Fields!Numbers.Value, ", ")(3))=false, Int(Split(Fields!Numbers.Value, ", ")(2)) , Int(Split(Fields!Numers.Value, ", ")(3)))

Structurally it looks sound, but the error handling behind the scenes flags it as an error. Does anyone else have this problem or know how to fix it

Thanks for your help.



Answer this question

Strings, Splitting, and Numerics

  • GaryDeMott

    IIF(IsNumeric(Split(Fields!Numbers.Value, ", ")(3))=false, Int(Split(Fields!Numbers.Value, ", ")(2)) , Int(Split(Fields!Numers.Value, ", ")(3)))


    I don't know if this was just a typo or if you copy/pasted your code, but I am thinking it should be Numbers, not Numers on the third line.


  • MarkWHarrison

    Oops. Yeah that is just a typo. My bad, but the problem is the same even when spelled correctly. :)

    Thanks Crax123


  • johnGa

    I suspect the Int() casting is causing the problem. In the "if false" part of the IIF function you attempt to cast a value to Integer that has already failed IsNumeric.

    This expression works for me if I remove the call to Int().

    -Chris



  • Bruff

    Thanks for your help. You are correct, but let's say we change the expression to:

    IIF(IsNumeric(Split(Fields!Numbers.Value, ", ")(3))=false, Split(Fields!Numbers.Value, ", ")(2) * -1 , Split(Fields!Numbers.Value, ", ")(3) *-1 )

    This expression won't work either. Somewhere it is evaluating the whole expression and see the last value as string even though it shouldn't because the false section of the if statement should be ignored.

    Chris_21


  • Strings, Splitting, and Numerics