How to right justify a character value in Smartlist?
The goal is to have NULL quantity values display as BLANK and any valid numbers (including zero) to display as a two decimal number (e.g. 123,456.78). Right now, Smartlist builder displays a ZERO amount if the underlying value is NULL.
Lastly, I did try padding each value with leading spaces so that each returned value has the same length (e.g. “12.34 and _2.34”), but Smartlist builder appears to be stripping away the leading spaces.
I am not sure how you are doing this in your view, but it almost sounds like whatever is being done in the view, SmartList Builder thinks it is a string field instead of numeric if it isn’t right aligning. You can create a calculated field in SLB that will cast the string to numeric if needed.
If it is a numeric value in SmartList Builder, it will always display a 0 when there isn’t a value or it is NULL.. That is how the numeric field works within SmartList.
Hi Nicole,
The view is passing back STRINGS. The originating numeric values are being to STRINGS. The reason we are passing back a STRING instead of a NUMERIC value is that if the resulting field in the View’s Query returns a NULL value, we want to display a SPACE/BLANK, if the value is zero, the we would display 0.00 and any other value would be a numeric value that we convert to have comma separators (e.g. 123,456.78).
If we pass values back as NUMERIC, then the NULL values are displayed as 0.00 in Smartlist, which we do NOT want. That is why we are converting values in the View to Character (e.g. case when [queryvalue] is null then ” else convert(varchar, cast(queryvalue as money), 1) end as Result_As_String)
So, is there a way of displaying a NULL value as spaces if the type is NUMERIC or is there a way of right justifying a STRING field in SmartList Builder?
As a temporary workaround, we are padding the front of the strings being past back with Invisible Characters. For example, if the longest number for a particular column would be seven characters (e.g. 1,345.78) and the value being passed back were say only four (e.g. 1.34), then we would pad the returned string with 4 invisible characters (e.g. ” 1.34″). Padding the field with leading spaces doesn’t work because SmartList strips them away when it right justifies the returned string.
Thanks,
Michael.