Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
abhaysingh
Specialist II
Specialist II

Logic Help

Hi Guys,

I have one scenario in which i need to do below transformation

i have customer data like below

Customer

0000012234

0000043210

00000REPLU

67890

123445

Total length of the customer is 10 always, what i need to do is if the length is less than than it will automatically add zeros before the number,

e.g. in my case 67890 shud be 0000067890

     and 123445 shud be           0000123445

9 Replies
Chanty4u
MVP
MVP

Num(customer,'0000')

MK_QSL
MVP
MVP

Load Num(Customer,'0000000000') as Customer Inline

[

  Customer

  0000012234

  0000043210

  00000REPLU

  67890

  123445

];

sunny_talwar

Try this:

TAB1:

LOAD *,

  If(Len(Customer) < 10, Repeat(0, 10 - Len(Customer)) & Customer, Customer) as CUS;

LOAD * INLINE

[

Customer

0000012234

0000043210

00000REPLU

67890

123445

];


Capture.PNG

MK_QSL
MVP
MVP

OR

Load

  If(Len(Customer) < 10, Text(Repeat(0,10-Len(Customer)))&Customer,Customer) as Customer

Inline

[

  Customer

  0000012234

  0000043210

  0000REPLU

  67890

  123445

];

Ohhh... Sunny T already replied the same...

abhaysingh
Specialist II
Specialist II
Author

Hi Guys ,


below also working for me

LEFT('0000000000', 10 - LEN(CUSTOMER)) & CUSTOMER

ali_hijazi
Partner - Master II
Partner - Master II

you can use the repeat function

Load repeat('0',10-Len(Customer) & Customer as Customer

from your_data_source

I can walk on water when it freezes
abhaysingh
Specialist II
Specialist II
Author

tried but not working

sunny_talwar

I think there is missing parenthesis, try this:

LOAD Repeat('0',10-Len(Customer)) & Customer as Customer

Anonymous
Not applicable

T1:

LOAD * INLINE [

Customer

  0000012234

  0000043210

  0000REPLU

  67890

  123445

  ];

T2:

NoConcatenate Load

Customer,

Repeat('0',10-len(Customer))&Customer as New

Resident T1;

Img1.PNG