Search code examples
sqlreporting-servicesssrs-2012

How to format a SSRS field with 2-digits of procession when the data is a mix of formats


I have data from a Stored Procedure that looks like this and needs to display on my report with 2-digits of precision. The data is all NVARCHAR but there is a mix of rows that looks numeric or says 'Max'.

enter image description here

How do I display only 2 digits of precision? I tried the following which works great on the numeric looking data but errors on 'Max'.

=FormatNumber(Fields!TBS.Value, 2)

Solution

  • Use an IIF to determine if the value is a number and IIF so, format it.

    =IIF(ISNUMERIC(Fields!TBS.Value), FormatNumber(Fields!TBS.Value, 2), Fields!TBS.Value)
    

    IsNumeric:

    Returns a Boolean value indicating whether an expression can be evaluated as a number.

    MS SSRS Description