This is a migrated thread and some comments may be shown as answers.

Dynamically set Format string in Crosstabl column

3 Answers 240 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
Peterson Mwangi
Top achievements
Rank 1
Peterson Mwangi asked on 07 Dec 2016, 08:37 AM

Hi,

I have a crosstab in a Telerik report. One of the columns in the crosstab display data of numeric type. Depending on user setting, I would wish to format the column with 0,1 or 2 decimal places. At the moment, the Format is "{0:#,##0.00;(#,##0.00);-}". However, I would wish to set this at runtime and not statically as is the case now.

Please assist.

Peterson

3 Answers, 1 is accepted

Sort by
1
Accepted
Stef
Telerik team
answered on 08 Dec 2016, 01:07 PM
Hello Peterson,

Please test using the built-in Conditional and Text functions to create an expression that changes the format based on data e.g.:
=IIf(Fields.Date.Hour=0 AND Fields.Date.Minute=0 AND Fields.Date.Second=0,
Format('{0:M}',Fields.Date),
Format('{0:g}',Fields.Date))
or
=Format('{0:c'+CStr(Fields.NumberOfDigits)+'}', Fields.NumericField)
The expression can be used as TextBox.Value property.

Regards,
Stef
Telerik by Progress
Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Feedback Portal and vote to affect the priority of the items
0
Peterson Mwangi
Top achievements
Rank 1
answered on 09 Dec 2016, 09:13 AM

Dear Stef,

Worked like magic! Thank you so much!

Regards,

Peterson

0
Peterson Mwangi
Top achievements
Rank 1
answered on 09 Dec 2016, 09:13 AM

Dear Stef,

Worked like magic! Thank you so much, appreciated!

Regards,

Peterson

Tags
General Discussions
Asked by
Peterson Mwangi
Top achievements
Rank 1
Answers by
Stef
Telerik team
Peterson Mwangi
Top achievements
Rank 1
Share this question
or