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 » Mon Dec 21, 2020 5:36 pm

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: 4053
Joined: Tue Mar 20, 2018 5:34 am

Re: Dynamic number formating based on data value

Post by Lech Kulikowski » Mon Dec 21, 2020 8:02 pm

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 » Tue Dec 22, 2020 6:40 am

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

Re: Dynamic number formating based on data value

Post by HighAley » Tue Dec 22, 2020 3:09 pm

Hello,

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

Thank you.
Post Reply