Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Any way to add trailing spaces i.e. pad data out

Hi,

I have a field from sql data i.e. MyField but I need it to be padded to 40 characters with trailing spaces in a chart i.e. MyFieldSSSSSSSSSSSSSSSSS

(where S is a space)

I know there are sql functions..

i.e. to pad to a certain length (20, in this example): left('MyText' & space(20), 20)


..but QV script does not like this.


Does anyone know  either a script or an expression function that could achieve this please ?


Thanks in advance

Bob

1 Solution

Accepted Solutions
Gysbert_Wassenaar

Something like this: MyField & Repeat(' ', 40 - len(MyField))


talk is cheap, supply exceeds demand

View solution in original post

4 Replies
Gysbert_Wassenaar

Something like this: MyField & Repeat(' ', 40 - len(MyField))


talk is cheap, supply exceeds demand
Not applicable
Author

Thank you - that worked perfectly !!

jldengra
Creator
Creator

In addition, I would say that sometimes repeating the character ' ' is not enough to add spaces at the left for indentation because they are trimmed and ignored. In those cases, a workaround is to repeat the tab character Chr(9) instead of ' ' to get the desired indentation.

warkg
Contributor II
Contributor II

I'm trying to left pad the field with spaces with no luck, it keeps getting trimmed.  Any other ideas?

Here is what I've tried:

='My Label: ' & Repeat(' ', 20-len(MY_FIELD)) & MY_FIELD

='My Label: ' & Repeat(Chr(9), 20-len(MY_FIELD)) & MY_FIELD

='My Label: ' & Repeat(" ", 20-len(MY_FIELD)) & MY_FIELD