Page 1 of 1

Dynamic number formating based on data value

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

Re: Dynamic number formating based on data value

Posted: Mon Dec 21, 2020 8:02 pm
by Lech Kulikowski
Hello,

No, there is no easy way.

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

Thank you.

Re: Dynamic number formating based on data value

Posted: Tue Dec 22, 2020 6:40 am
by pvb
Thank you for the answer.

Re: Dynamic number formating based on data value

Posted: Tue Dec 22, 2020 3:09 pm
by HighAley
Hello,

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

Thank you.