Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

How To Remove Leading Zeros in a Number


Hi All,

I have a field with the following values

00000978

00001524

00001024

00012356

The field is in number format.

The length of the field is constant and it is 8.

I would like to remove the leading zeros and would like to have the values as follows:

978

1524

1024

12356

Kindly help me to get the above output.

Thanks in Advance!!

Regards,

Vinitha.

10 Replies
MayilVahanan

Hi

Try like this

Num(Num#(FieldName,'#,##0'),'#,##0') AS FieldName;

or

Num(FieldName)

Thanks & Regards, Mayil Vahanan R
Please close the thread by marking correct answer & give likes if you like the post.
nagaiank
Specialist III
Specialist III

Use the script below

LOAD *, Number8digit+0 As Number;
LOAD * Inline [
Number8digit
00000978
00001524
00001024
00012356
]
;

Capture.PNG.png

MK_QSL
MVP
MVP

Load

  NUMBER,

  Num(NUMBER) as NUMBER1,

  NUM(Right(NUMBER, Len(NUMBER)-FindOneOf(NUMBER, '123456789')+1)) as NUMBER2

Inline

[

  NUMBER

  00000978

  00001524

  00001024

  00012356

];

ashfaq_haseeb
Champion III
Champion III

Hi,

You can try below code.

LOAD *,

replace(ltrim(replace(Number, '0', ' ')), ' ', 0) as New_Number;

LOAD * Inline [

Number

00000978

00001524

00001024

00012356

];

Regards

ASHFAQ

MarcoWedel

Num(YourField)


should be the easiest way.

Not applicable
Author

Hi Vinitha

you can perform below code in your existing work space. try to run below and check.

Load

  NUMBER,

  Num(NUMBER) as NUMBER1,

  NUM(Right(NUMBER, Len(NUMBER)-FindOneOf(NUMBER, '123456789')+1)) as NUMBER2

Inline

[

  NUMBER

  00000978

  00001524

  00001024

  00012356

];




fabioporta
Contributor
Contributor

Mid(FieldValue, FindOneOf(FieldValue,'123546789'))

Femke
Contributor III
Contributor III

this worked for me:

Num(Num#(yourfield,'#,##0'),'#0') AS FieldName

 

 

suepenick
Creator
Creator

this one worked perfectly