Showing posts with label conditionally. Show all posts
Showing posts with label conditionally. Show all posts

Friday, February 24, 2012

Format Decimal number conditionally

My 'Hour' Fields are retrieved from stored procedure always with 1 decimal
place.
(ie: 2.0 hours, 3.5 hours)
I wish to display, (ie: 2, 3.5 respectively), the first value (2.0) without
the ".0".
So far I have this solution:
=IIF(Abs(Fields!Hours.Value) < Fields!Hours.Value, Fields!Hours.Value ,
Abs(Fields!Hours.Value) )
Is there a better solution? thanks!I found an even simpler solution:
I changed the Custom Format of my table cell to:
=Format(Cdbl(Fields!Hours.Value))
"SQT" wrote:
> My 'Hour' Fields are retrieved from stored procedure always with 1 decimal
> place.
> (ie: 2.0 hours, 3.5 hours)
> I wish to display, (ie: 2, 3.5 respectively), the first value (2.0) without
> the ".0".
> So far I have this solution:
> =IIF(Abs(Fields!Hours.Value) < Fields!Hours.Value, Fields!Hours.Value ,
> Abs(Fields!Hours.Value) )
> Is there a better solution? thanks!
>|||Apology.
Do not use the Custom Format.
Change the Text Value Property to, ie: =Format(Cdbl(Fields!Hours.Value))
"SQT" wrote:
> I found an even simpler solution:
> I changed the Custom Format of my table cell to:
> =Format(Cdbl(Fields!Hours.Value))
>
> "SQT" wrote:
> >
> > My 'Hour' Fields are retrieved from stored procedure always with 1 decimal
> > place.
> > (ie: 2.0 hours, 3.5 hours)
> >
> > I wish to display, (ie: 2, 3.5 respectively), the first value (2.0) without
> > the ".0".
> > So far I have this solution:
> > =IIF(Abs(Fields!Hours.Value) < Fields!Hours.Value, Fields!Hours.Value ,
> > Abs(Fields!Hours.Value) )
> >
> > Is there a better solution? thanks!
> >