Sunday, February 19, 2012

Format Currency - values include NaN

Hi, my report includes a calculated column which I wish to display as
currency.
Unfortunately, some of the calculated values are non-numeric. My report
shows these values as 'NaN'. I would like to display something a bit more
meaningful to the user such as '-'. Is there a way of doing this?Nic wrote:
> I would like to display
> something a bit more meaningful to the user such as '-'. Is there a
> way of doing this?
Write a piece of custom-code like this:
Function CheckValue(value as object) as object
If isnumeric(value) Then
Return FormatCurreny(value)
Else
Return "This is no numeric value"
End If
End Function
and put an expression in the field like:
=code.CheckValue(Fields!MyField.Value)
Maybe you have to play with field-property..i assumed "Standard"
regards
Frank
www.xax.de|||Frank,
Thanks for the information. However, I tried the function you suggested and
the isnumeric function appears to return true for those values which are NaN.
In any case, my report still contains NaN values, which have not been
replaced by the 'This is no numeric value' message. I know that the function
is being used, and I can change what is displayed by changing what is
returned when the isnumeric function is evaluated as true.
Any suggestions?
"Frank Matthiesen" wrote:
> Nic wrote:
> > I would like to display
> > something a bit more meaningful to the user such as '-'. Is there a
> > way of doing this?
> Write a piece of custom-code like this:
> Function CheckValue(value as object) as object
> If isnumeric(value) Then
> Return FormatCurreny(value)
> Else
> Return "This is no numeric value"
> End If
> End Function
> and put an expression in the field like:
> =code.CheckValue(Fields!MyField.Value)
> Maybe you have to play with field-property..i assumed "Standard"
> regards
> Frank
> www.xax.de
>
>
>|||Hi,
I have done a bit more investigation, and have come up with the following,
which seems to work. I would dearly like to know whether this can be
simplified, Franks suggestion seems neater, but I cannot get it to work - any
ideas why?
Function CheckValue(value as object) as object
If IsNum(value) Then
Return FormatCurrency(value)
Else
Return "-"
End If
End Function
Function IsNum(value as object) as boolean
Try
Decimal.Parse(value)
Return True
Catch
Return False
End Try
End Function
"Nic" wrote:
> Frank,
> Thanks for the information. However, I tried the function you suggested and
> the isnumeric function appears to return true for those values which are NaN.
> In any case, my report still contains NaN values, which have not been
> replaced by the 'This is no numeric value' message. I know that the function
> is being used, and I can change what is displayed by changing what is
> returned when the isnumeric function is evaluated as true.
> Any suggestions?
> "Frank Matthiesen" wrote:
> > Nic wrote:
> >
> > > I would like to display
> > > something a bit more meaningful to the user such as '-'. Is there a
> > > way of doing this?
> >
> > Write a piece of custom-code like this:
> >
> > Function CheckValue(value as object) as object
> > If isnumeric(value) Then
> > Return FormatCurreny(value)
> > Else
> > Return "This is no numeric value"
> > End If
> > End Function
> >
> > and put an expression in the field like:
> > =code.CheckValue(Fields!MyField.Value)
> >
> > Maybe you have to play with field-property..i assumed "Standard"
> >
> > regards
> >
> > Frank
> > www.xax.de
> >
> >
> >
> >
> >

No comments:

Post a Comment