Tabular Currency Alignment for Negative and Positive Numbers

4 posts, 1 answers
  1. Steven
    Steven avatar
    6 posts
    Member since:
    Jul 2015

    Posted 26 Dec 2019 Link to this post

    We have reports that show dollar amounts and discounts for services in a table.  The discounts are negative numbers with a financial format that puts them in ().  In the attachment, the columns of numbers going from positive to negative are not aligned.  Is there a way to handle this so the numbers (regardless of being positive or negative) are aligned vertically?
  2. Answer
    Todor
    Admin
    Todor avatar
    451 posts

    Posted 31 Dec 2019 Link to this post

    Hi Steven,

    The requirement can be achieved with Padding set with Conditional Formatting or Bindings, or with special invisible symbols. I have attached a report demonstrating both approaches. Next, I will describe them briefly.

    1. Padding

    I have used Bindings in the 'Base Rate' column of the table to set the Right Padding to '1.8mm' when the displayed value is non-negative, and to 0 otherwise - check the screenshot 'PaddingWithBindings.png'. This way, the additional ')' character in negative values was compensated with padding to allow for the numbers to be aligned. Note that with this approach when changing the Font it may be necessary to change also the padding.

    2. Invisible character.

    You may also use the Format Text function and add an additional invisible symbol after the numbers for the non-negative values. Importantly, we trim the regular whitespace, so it will be necessary to choose another invisible symbol. I used the space character "U+2004 | &#8196 | Three-Per-Em Space" - check Unicode empty characters, where I copied the symbol from. This approach is demonstrated in the table column 'Service Fee'. Here is the Value for the TextBox:

    = IIF(Fields.[Service Fee] >= 0,
            Format("{0:c2}{1}", Fields.[Service Fee], ' '),
            Format("{0:c2}", Fields.[Service Fee]))

    The {1} parameter is replaced with the 'Three-Per-Em Space' character to compensate for the ')' symbol in the negative values.

    Regards,
    Todor
    Progress Telerik

    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
  3. Steven
    Steven avatar
    6 posts
    Member since:
    Jul 2015

    Posted 02 Jan in reply to Todor Link to this post

    Thank you for this.  I am using an older version of Reporting so I cannot open your example report. Can you reply with the expression used in the Binding?
  4. Todor
    Admin
    Todor avatar
    451 posts

    Posted 06 Jan Link to this post

    Hi Steven,

    Here is the Binding for setting the right padding:

    Property path			|	Expression
    Style.Padding.Right	|	= IIf(Fields.[Base Rate] >= 0, '1.8mm', '0mm')

    I am re-attaching the TRDX report converted to R1 2018. It can be opened with the specified or newer version of the Standalone designer. If you need the sample in an even older version just open the TRDX file in a text editor and change the schema on the second row to the one corresponding to the version - check XML Schema article section and Upgrade Path.

    Regards,
    Todor
    Progress Telerik

    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
Back to Top