Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
nevilledhamsiri
Specialist
Specialist

How to format a cell with fixed characters!

Hi, Dear all,

Please help me to achieve following objectives!


1st Scenario!

I have set of employees whose ref_numbers are varied. It is said that every code should carries 5 characters. Hence all numbers less than 5, need to have zero value in front of them.

2nd Scenario!

If I need to add zero value behind the numbers which are less than 5 characters how that be achieved!

Thanks

Neville

1 Solution

Accepted Solutions
Frank_Hartmann
Master II
Master II

Load *, if(len(REF_CODE)<5,REF_CODE&0,REF_CODE) as RefCodeNew;

LOAD * INLINE [

    REF_CODE

    2535

    6530

    7523

    12545

    15128

];

View solution in original post

5 Replies
m_woolf
Master II
Master II

This is best done in load script.

Scenario 1:

     if(Len(REF_CODE)=5,REF_CODE,repeat('0',5-len(REF_CODE)) & REF_CODE) as REF_CODE,

nevilledhamsiri
Specialist
Specialist
Author

Thanks MW,

1st  Scenario turns alright!, How I will achieve the 2nd scenario?

Thanks

Neville

Frank_Hartmann
Master II
Master II

Load *, if(len(REF_CODE)<5,REF_CODE&0,REF_CODE) as RefCodeNew;

LOAD * INLINE [

    REF_CODE

    2535

    6530

    7523

    12545

    15128

];

nevilledhamsiri
Specialist
Specialist
Author

Dear Frank,

This is alright

Thanks

Neville

m_woolf
Master II
Master II

Frank's answer will work only for numbers of 4 digits.

Scenario 2:

     if(Len(REF_CODE)=5,REF_CODE, REF_CODE & repeat('0',5-len(REF_CODE))) as REF_CODE,