martavoi
martavoi

Reputation: 7092

SSRS FormatNumber Error

trying to format number (decimal), but it shows me #Error on production server:

=FormatNumber(First(Fields!SumWithMailDelivery.Value, "document"), 0)

but on developers server it works fine. Maybe someone know, how can i resolve this?

p.s. without formatting it works on production server fine too.

Upvotes: 2

Views: 1452

Answers (1)

Chris Latta
Chris Latta

Reputation: 20560

As @IanPreston says, it is most likely a type conversion error. I imagine your production data has some invalid characters for that column or some Null columns that make the numeric conversion fail.

You can use the Val function to do the conversion. Val differs from other numeric conversion functions in that it won't error when the string to be converted isn't numeric - it just does the best job it can.

So try an expression like this for the Value property:

=IIF(Fields!SumWithMailDelivery.Value Is Nothing, 
  Nothing, 
  IIF(IsNumeric(Fields!SumWithMailDelivery.Value), 
    Val(Fields!SumWithMailDelivery.Value), 
    Fields!SumWithMailDelivery.Value)
)

then use N0 as the Format property to format it as numeric if possible.

This formula will:

  • Leave the cell as Nothing if the field is Null
  • Convert to numeric and use the appropriate format if possible
  • Otherwise just output whatever is in the field

Upvotes: 3

Related Questions