Skip to main content
Announcements
Qlik Connect 2025: 3 days of full immersion in data, analytics, and AI. May 13-15 | Orlando, FL: Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
JorgeH
Contributor II
Contributor II

Complete data with a number of 0

The lenght of a text field contains 12 characters, however, there are data with less than 12 characters (all of them). What I need is to complete each register of the text field with 0 (ceros) till complete 12 characters in total. I appreciate your help. 

2 Solutions

Accepted Solutions
Vegar
MVP
MVP

Try

Right('000000000000' & YourTextField, 12) as YourField

View solution in original post

Vegar
MVP
MVP

You can solve the subsequent zeros with adjustments to the previous suggested approach.  

LOAD
Value,
right('000000000000' & Value, 12) as Preceding,
left(Value & '000000000000', 12) as Subsequent
inline [
   Value
   7525963 
   25
   112233445566778899
];

image.png

Please observe that if your Value consists of more than 12 characters it will be cropped by this approach.

View solution in original post

4 Replies
Vegar
MVP
MVP

Try

Right('000000000000' & YourTextField, 12) as YourField

JorgeH
Contributor II
Contributor II
Author

Thank you,

No problem. I appreciate you help.

The issue is that there are some registers, one with 7 characters, another one wiht 2 characters, and so on.

I have to complete with 0 to the right to each of them until complete 12 characters,

For example, if one register is: "7525963" is has to be "752596300000"

If the other one is: "25" it has to be "25000000000000"

🙂

 

Vegar
MVP
MVP

You can solve the subsequent zeros with adjustments to the previous suggested approach.  

LOAD
Value,
right('000000000000' & Value, 12) as Preceding,
left(Value & '000000000000', 12) as Subsequent
inline [
   Value
   7525963 
   25
   112233445566778899
];

image.png

Please observe that if your Value consists of more than 12 characters it will be cropped by this approach.

JorgeH
Contributor II
Contributor II
Author

Excelent, Well done !!! Vegar, I appreciate !.

In your first solution, one could also be use:

Left([Field_Name] & '000000000000',  12) as NewField

However, your second alternative is complete and better, also.

Many thanks,

JorgeH