Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

PADLEFT for a range of numbers and get all outputs

shobhit_gupta
7 - Meteor

Hello all,

 

I have a string (ex: 34567891). I want to append zeros to the left of this string until total length is 17. I know that it could be achieved by using PADLEFT(my_string_field, 17,'0'). But it will give me only one output i.e.

 00000000034567891.
But what I want as output is all values till length 17 is reached.

Something like this:

034567891 -  length 9

0034567891  -  length 10

00034567891 -  length 11

000034567891 -  length 12

0000034567891 -  length 13

00000034567891  -  length 14

000000034567891 -  length 15

0000000034567891 -  length 16

00000000034567891 -  length 17

 

How do I achieve this ?

6 REPLIES 6
Prometheus
12 - Quasar

@shobhit_gupta I used a Text Input tool with numbers 9 through 17 (Number) then called that in my PadLeft expression in the Formula tool.

Text input numbers.PNG

PadLeft.PNG

shobhit_gupta
7 - Meteor

Thank you @Prometheus . But the thing is, my input string will not always be of length 8. It could be like 34567 also. In this case, we'll have to start from 7 in the text input tool. how do we change it in the text input tool depending on the length of the input string and increment it by 1 till length 17 is reached ?

tirthin8
5 - Atom

I would use a formula tool to hard code Length as 17 and String Length as the length of input string. Then I would use the Generate Rows tool to update String Length until String Length is 17. Then I would simply use the PadLeft.

 
 

Image.JPG

shobhit_gupta
7 - Meteor

Hi @tirthin8 , can you please share the screenshot of generate rows tool ?

tirthin8
5 - Atom

Image2.JPG

 

Let me know if this works for you.

shobhit_gupta
7 - Meteor

Thank you so much! This is very helpful and fits perfectly for my use case.

Labels
Top Solution Authors