Qlik Community

Qlik Sense App Development

Discussion board where members can learn more about Qlik Sense App Development and Usage.

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

Tags (1)
1 Solution

Accepted Solutions

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

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

3 Replies

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

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

Not applicable

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

Thank you - that worked perfectly !!

jldengra
Contributor

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

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.