Qlik Community

QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Share your QlikView feedback with the product team… Click here to participate in our 5-minute survey.
Rules, plus terms and conditions, can be found here.
hmjason7
New Contributor

Convert String to Number

Hi All,

I need to convert a 16 character string into a number. The tricky thing is, the field is always a 16 character string in the form of:

"000000000001234" or "000000132454623" or "000000012300433".

As the last example suggests, I cannot simply trim all the 0's from the left hand side.

Any help would be much appreciated.

Cheers,

Jason

1 Solution

Accepted Solutions
MVP
MVP

Re: Convert String to Number

Temp:

Load Num(Evaluate(Field),'#0') as Field Inline

[

  Field

  000000000001234

  000000132454623

  000000012300433

];

5 Replies
MVP
MVP

Re: Convert String to Number

Temp:

Load Num(Evaluate(Field),'#0') as Field Inline

[

  Field

  000000000001234

  000000132454623

  000000012300433

];

hrlinder
Honored Contributor

Re: Convert String to Number

do you need the "0" also in form of number?

then use

num(stringnumber,'0000000000000000')

should work

or what do you want?

hmjason7
New Contributor

Re: Convert String to Number

Thanks, works like a charm.

hmjason7
New Contributor

Re: Convert String to Number

No I didn't need the 0. So if it was "000000000001234", I just wanted to return '1234.

awhitfield
Esteemed Contributor

Re: Convert String to Number

You could also try this


LOAD
replace(ltrim(replace(number, '0', ' ')), ' ', 0) as number

Regards

Andy

Community Browser