Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Join us to spark ideas for how to put the latest capabilities into action. Register here!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

function num() for the string

Hello,

In my script, I would like to do like the num() function, but for the string.

for example :

Y = 50

X = num(Y,0000);

==> then X = 0050.

I need to do the same but with the blank character (before or after). if Y = 50, I need to have X = '  50' or X = '50  '

A function is available for this ?

Thanks in advance.

1 Solution

Accepted Solutions
Miguel_Angel_Baeyens

Hi,

Do you mean this?

=Text(Repeat(' ', 4 - Len(Y)) & Y)

4 is the fixed length of the maximum number of chars that your string should have. If Y = 50, then it will add two spaces before the value of Y. Similarly, you can do it to put the spaces after the value of Y:

=Text(Y & Repeat(' ', 4 - Len(Y)))

Hope that helps.

Miguel

View solution in original post

3 Replies
Miguel_Angel_Baeyens

Hi,

Do you mean this?

=Text(Repeat(' ', 4 - Len(Y)) & Y)

4 is the fixed length of the maximum number of chars that your string should have. If Y = 50, then it will add two spaces before the value of Y. Similarly, you can do it to put the spaces after the value of Y:

=Text(Y & Repeat(' ', 4 - Len(Y)))

Hope that helps.

Miguel

Not applicable
Author

it works, thanks you.

but now I will try to solve my last problem : I think it's a problem with a proportionnal font.

because I have now :

   5000

    5000

  5000

   5000

Miguel_Angel_Baeyens

Hi,

It seems you need some trimming in your results, or better in your input code:

Text(Repeat(' ', 4 - Len(Trim(Y))) & Trim(Y))

Hope that helps

Miguel