Dynamic number formating based on data value

Stimulsoft Reports.PHP discussion
Post Reply
pvb
Posts: 8
Joined: Tue Oct 13, 2020 3:40 pm

Dynamic number formating based on data value

Post by pvb »

Let's have a datasource MyData with values

ID| Value | Resolution
1 | 123.456 | 3
2 | 123.456 | 0
3 | 123.456 | 2

I want to display Value with decimal places defined in Resolution. So in consecutive detail sections each Value should be formated differently. Like this:

123,456
123
123,46

Now to achieve this I use the expression:

Code: Select all

{Replace(Format("{0:N"+MyData.Resolution+"}", MyData.Value), " ", ",")} 
Is there an easier way to format text fields bases on value from current record in datasource?
Something like N{MyData.Resolution} ?

Thank you.
Lech Kulikowski
Posts: 6163
Joined: Tue Mar 20, 2018 5:34 am

Re: Dynamic number formating based on data value

Post by Lech Kulikowski »

Hello,

No, there is no easy way.

Also, may be used
{Format("{" + Format("0:F{0}", digits) + "}", value)}

Thank you.
pvb
Posts: 8
Joined: Tue Oct 13, 2020 3:40 pm

Re: Dynamic number formating based on data value

Post by pvb »

Thank you for the answer.
HighAley
Posts: 8430
Joined: Wed Jun 08, 2011 7:40 am
Location: Stimulsoft Office

Re: Dynamic number formating based on data value

Post by HighAley »

Hello,

we are always glad to help you.
Let us know if you need any additional help.

Thank you.
Post Reply