Skip to main content
Answer

Decimal align numbers (not right align)

  • August 3, 2024
  • 11 replies
  • 89 views

Forum|alt.badge.img

Is there a formatting code that will decimal align numbers so that the decimal is aligned for both positive & negative numbers when you use brackets for negative numbers?  

Acumatica does this:

  1,000.00
(1,000.00)

instead of this

 1,000.00
(1,000.00)

TIA

Best answer by darylbowman

...right-hand side of positive values...

Something like this:

=IIf([SOLine.CuryLineAmt]>=0,Format('{0:#,##0.00} ',[SOLine.CuryLineAmt]),Format('({0:#,##0.00})',Abs([SOLine.CuryLineAmt])))

 

11 replies

nhatnghetinh
Captain II
Forum|alt.badge.img+11
  • Captain II
  • August 5, 2024

Hi @RHarrison 

I just came up with a way to use the IIF Function to do it as the following example.

=IIf( [SOLine.CuryLineAmt] < 0
    , '(' + Abs([SOLine.CuryLineAmt]) + ')'
    , [SOLine.CuryLineAmt] )

 

 

Best Regards,

NNT


darylbowman
Captain II
Forum|alt.badge.img+15

@nhatnghetinh - This doesn't solve the question. It's a spacing problem, not a formatting problem (although it's not super clear because of the way the post is formatted)

Acumatica does this:

   1,000.00
(1,000.00)

instead of this

 1,000.00
(1,000.00)

 

However, you could use an IIf statement to pad the non-negative numbers with a space.


darylbowman
Captain II
Forum|alt.badge.img+15

@RHarrison Did you get this resolved?


Forum|alt.badge.img
  • Author
  • Freshman II
  • August 8, 2024

@RHarrison Did you get this resolved?

Nope.  I’ve tried formatting like this #,###.00;(#,###.00) but that gives me the out of alignment result.  I can’t figure out want to put before the semicolon to give me a space after the positive number.  I’m guessing there might be an ascii code to represent a hard space but I haven’t looked that up yet.  I’m also not sure out to enter it in the report writer.

Any suggestions?


darylbowman
Captain II
Forum|alt.badge.img+15

You may have a couple options. You can try using a non-space whitespace character. There are quite a few described in this post. You can use the Character Map program that ships with Windows to find them by their Unicode number:

 

I would just paste them into the format line and see if they stick. If not, you can go the route of manually formatting them with either the Format function (ie =Format()) or using an IIF.

Let me know how it goes or if you have any questions.


Forum|alt.badge.img
  • Author
  • Freshman II
  • August 9, 2024

You may have a couple options. You can try using a non-space whitespace character. There are quite a few described in this post. You can use the Character Map program that ships with Windows to find them by their Unicode number:

 

I would just paste them into the format line and see if they stick. If not, you can go the route of manually formatting them with either the Format function (ie =Format()) or using an IIF.

Let me know how it goes or if you have any questions.

Tried them all.  Not only did they not work, but they caused the report to error out.  If I try to validate the field once pasting in any of these codes, the validation fails.

I’m going to keep trying though.


Forum|alt.badge.img+8
  • Semi-Pro I
  • August 9, 2024

Hi @RHarrison Try the formula with a space as below and let us know your feedback.

=IIf( [SOLine.CuryLineAmt] < 0
    , ' (' + Abs([SOLine.CuryLineAmt]) + ')'
    , [SOLine.CuryLineAmt] )


Forum|alt.badge.img+8
  • Semi-Pro I
  • August 9, 2024

Hi @RHarrison To be more clear, please note the space added(Highlghted in yellow) as below in the formula:
 

 


darylbowman
Captain II
Forum|alt.badge.img+15

@ChandraM - If I’m not mistaken, you’d want the space on the right-hand side of positive values. The values are right-aligned.


Forum|alt.badge.img+8
  • Semi-Pro I
  • August 9, 2024

Hi @darylbowman Thanks for the update. Wonderful!

@RHarrison  So the revised formula will be as shown below:

=IIf( [SOLine.CuryLineAmt] < 0
    , '(' + Abs([SOLine.CuryLineAmt]) + ') '
    , [SOLine.CuryLineAmt])
 

 


darylbowman
Captain II
Forum|alt.badge.img+15
  • Answer
  • August 9, 2024

...right-hand side of positive values...

Something like this:

=IIf([SOLine.CuryLineAmt]>=0,Format('{0:#,##0.00} ',[SOLine.CuryLineAmt]),Format('({0:#,##0.00})',Abs([SOLine.CuryLineAmt])))