Skip to content
+1-888-319-3663

COMMUNITY FORUM

How to right justify a character value in Smartlist?

Michael Nola asked 7 years ago
Created a special View that converts all numbers to comma separated number fields (e.g. 123,456.78) if the value is NOT Null.  If the value is NULL, then return a BLANK value is returned.  The problem I’m having is getting the numeric Character field to display RIGHT justified, so that the number values line up.
 
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.
 
Answers
Nicole Albertson Staff answered 7 years ago
Are you getting this data out of a GP table or another table so that we can test this out?  Does the data have the decimal places in it and you are just adding the commas? 

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.
Michael Nola replied 7 years ago

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.


If you would like to submit an answer or comment, please sign in to the eOne portal.