1

Question : I have a field column that is has numbers with percent. The field properties are string and 50 in length. I ran it in an expression using round([T_Acres]/207 * 100,0) + "%" in VB script . It works; however there is one problem... it is to the left justified and I want to change that from left to right.

4
  • 4
    The left indent is due to the fact that by appending a "%" sign to the end of the number, it is being cast to a string. This is expected behavior, if you open excel and type 10 and "10%" is two cells, you will get the same result. – John Powell Oct 26 '14 at 16:29
  • 3
    Three issues here. One, why do you care whether it's right aligned or left aligned in the attribute table?. Two, as I believe was mentioned in one of your other questions, fields representing numerical values are usually a numeric data type, not text. You can set the display format for numerical values to percent if you want. Three, seeing as all your values are 0%, I'm not sure your field calculation actually worked. You may have valid responses to these issues; it would be helpful if you could explain your reasons for what you're doing/wanting. – recurvata Oct 26 '14 at 17:09
  • @recurvata - The Post_Acres you see above is the one that I re-calcuate after I clipped with the boundary. The 207 acres I took is from the boundary I ran to calcuate how many acres from that data and then use this number to run the equation I used to build the percent. Get it ? – PROBERT Oct 26 '14 at 19:07
  • 3
    @PROBERT you can label with [fieldname] & "%". Converting the numeral to string is not going to help with anything except labeling. Also, simply go to the field properties and change left or right justified, or do it in a label is my suggestion – Brad Nesom Oct 26 '14 at 22:05
3

In Python (using your example expression):

'{0:.0%}'.format(!T_Acres!/207.0).rjust(50)

That being said, I do have to agree with other comments on your question; I would not recommend doing this in most situations. It could make your data confusing to anyone else that is trying to view it and and it makes it makes it more complex than what is really need. Simple is generally better!

2
  • And even this hack isn't a true solution to what the OP wants, because it will be right-justified to a fixed width. If the column is displayed narrowly, the values will be hidden; if its very wide, the values will be somewhere in the middle of it. – nmpeterson Oct 27 '14 at 15:16
  • It worked but it depends on the column itself you would have to adjust the right justified number (50) to less number to show it. If you put 50 then the number will not display unless you drag the column to the right to be able to see it. It will still be there but the number will not show it. – PROBERT Oct 27 '14 at 15:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.