When I see this issue it is in a dashboard table visualization not in the search result. The number is shown correctly as a number (right justified) in search statistics view. Strings are shown left justified by default and numbers are right. In my case the issue concerns representing a number as currency in a dashboard.
So there is a clear indication that Amount can only be Null or a number. The eval is not necessary if you want to keep the original value completely in tact - I left it there to demonstrate as I was trying various things to force the table to display my value how I wished.
I use fieldformat since I wish to be able to drilldown on the actual value of Amount and not the string representation. Fieldformat works as intended however as OP noted, table visualization doesn't maintain the intended field's right justification.
To further enhance my dashboard relating to the "Amount" field I have the following.
My field should be right justified since I have "told" the table visualization it's a number in the specific way that is documented and the base search has resulted in the field being denoted with 'numeric' td class anyhow.
By this reasoning it's a bug because "table visualization does not respect numeric field right justification CSS directive".
My hack solution for dashboard: Of interest to me is that when I examine the html of the generated dashboard, the field in question is denoted with class=td.numeric which includes text-align:right however it's then overridden by the table class from dahsboard itself.
I assume the CSS defined within the dashboard xml has precedence over the generated CSS which is very handy indeed.
This will result in any numeric field in a table visualization in a dashboard maintaining the right justification that the developer of the table view in statistics view intended. Probably when that enhancement was made, no thought was given to the dashboard table visualization issue.
Note that Amount3 is rendered as string although it's being colored correctly as a number so it's a weird one. The table visualization is troubled by printf's attempt to left pad the value and ignores the padding however still thinks of the value as numeric in terms of the type="color" format block.
Finally my question: Is there something I've missed or a better way to handle this simple requirement? I want the dashboard table visualization to render numbers the same way as the search statistic view.