.net - Microsoft/SSRS report textbox returns #error when string value that is decimal is converted to decimal and empty string is just printed -


i have value coming database string, decimal , when decimal want display decimal , format way, if isn't decimal display whatever value comes back.

here's code:

=iif (     isnothing(fields!amount.value) or len(trim(fields!amount.value)) < 1,      fields!amount.value, //have tried cstr(fields!amount.value) in case conversion below makes report expect decimals values     iif     (         isnumeric(fields!amount.value),          cdec(fields!amount.value),         fields!amount.value     ) ) 

the comment above not part of code, put here. anyway, based on above, decimals converted decimals , display ok, strings either empty or hold non-numeric value show #error.

here's sample result display:

72.00 95.00 #error 20.00 

what's wrong expression? , why couldn't ssrs use c# instead of vb?!!?

update: know problem has conversion , not logic check whether value nothing, less 1 character, or numeric, because following works:

=iif (     isnothing(fields!amount.value) or len(trim(fields!amount.value)) < 1,      "is nothing or less 1",     iif     (         isnumeric(fields!amount.value),          "is numeric",         "is not numeric"     ) ) 

this correctly display:

is numeric numeric nothing or less 1 numeric 

iif function , arguments evaluated before function called. there no use in using iif prevent error.

i suppose need user defined function (writing custom functions in ssrs)

so instead iif(isnumeric(fields!amount.value),...)

define function

function decimalifpossible(value string) object   if isnumeric(fields!amount.value)       return  cdec(fields!amount.value)    else       return  fields!amount.value    end if end function 

and call decimalifpossible(fields!amount.value).


Comments

Popular posts from this blog

java - Run a .jar on Heroku -

java - Jtable duplicate Rows -

validation - How to pass paramaters like unix into windows batch file -