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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
sspawar88
Creator II
Creator II

Leading Zeros and Num(Field) Function

Hi Commuity,

To remove Leading zeros in following field we can use Num(Field) but it creates null for value of CGDF, GHJJJJ etc

Can we have any workaround solution at script level to keep the CGDF,GHJJJJ etc as it is and only remove those leading zeros

Field
0000154
005
CGFD
GHJJJJ
01

Output should be

154
5
CGFD
GHJJJJ
1
9 Replies
Anil_Babu_Samineni

May be using Keepchar / Purgechar

PurgeChar(Field, '0')

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
surendraj
Specialist
Specialist

May be like this

Trim(replace(Feild,'0',' '))

or

replace(Feild,'0','')

sspawar88
Creator II
Creator II
Author

if Field has a value like 000150 it will create 15.

i think it is not a perfect one here. in this case we want 150 (only removing leading zeros)

Anil_Babu_Samineni

Can you send real data. We can work for you if you provide 10-15 Records

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
surendraj
Specialist
Specialist

In such case

replace(ltrim(Replace('000150','0',' ')),' ',0)

replace(ltrim(Replace(Field,'0',' ')),' ',0)

MK_QSL
MVP
MVP

Data:

Load

  Field as OriginalField,

  Right(Field,Len(Field)-FindOneOf(Upper(Field),'ABCDEFGHIJKLMNOPQRSTUVWXYA123456789')+1) as NEW

Inline

[

  Field

  0000154

  005

  CGFD

  GHJJJJ

  01

];

sspawar88
Creator II
Creator II
Author

Anilbabu,

Values are just like original data. You can work on that

Anil_Babu_Samineni

Try this

LET Var1 = 1;

Right(Field,Len(Field)-FindOneOf(Upper(Field),'ABCDEFGHIJKLMNOPQRSTUVWXYA123456789')+'$(Var1)')


Update: Manish gave same check that and let us know

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
Anonymous
Not applicable

Try this

Replace(Field,0,'') as FieldN