Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

How to Delete leading zeros

Requirement is to delete fields starting with zeros and make it as NULL. Also keep NULL for alpha-numeric values.

  

Old FieldNew Field
00123Null
345345
045Null
0000563Null
65896589
34573457
asddNull
fgfdgNull
1 Solution

Accepted Solutions
sunny_talwar

Something like this

Table:

LOAD *,

  If(Left([Current Field], 1) = 0, 'Null', [Current Field]) as Output;

LOAD * INLINE [

    Current Field

    00123

    345

    045

    0000563

    5644

];

View solution in original post

13 Replies
micheledenardi
Specialist II
Specialist II

LOAD

  [Old Field],

  if(left([Old Field],1)=0,null(),num([Old Field])) as [New Field]

FROM [Cartel1.xlsx] (ooxml, embedded labels, table is Foglio1);

Michele De Nardi
If a post helps to resolve your issue, please accept it as a Solution.
tamilarasu
Champion
Champion

Hi Kirubakaran,

If(Left([Old Field],1) = 0 or IsText([Old Field]),Null(),[Old Field]) as [New Field];

Anil_Babu_Samineni

Is this you are expecting?

Capture.PNG

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
sunny_talwar

May be just Num(Num#(OldField)) as NewField

antoniotiman
Master III
Master III

Hi,

try

LOAD [Old Field],
If(Num([Old Field])=Text([Old Field]),[Old Field]) as New

Regards,

Antonio

tajmohamed30
Creator III
Creator III

Hi Nagaraj,

Please use below expression,

=trim(replace(OldField,0,' '))

Taj Mohamed

Anonymous
Not applicable
Author

My question was Replace rows to 'NULL' which starting with Zero

  

Current Field Output
00123Null
345345
045Null
0000563Null
56445644

LOAD * INLINE [

    Current Field

    00123

    345

    045

    0000563

    5644

];

sunny_talwar

Something like this

Table:

LOAD *,

  If(Left([Current Field], 1) = 0, 'Null', [Current Field]) as Output;

LOAD * INLINE [

    Current Field

    00123

    345

    045

    0000563

    5644

];

Not applicable
Author

Hello Kirubakaran,

I recommend you to take a look at the examples for the logical functions IsNum and IsText in the qlikview help.

PS: Don't forget to mark answers as helpful or correct.

,Greetz Hannah