# QlikView Scripting

Discussion Board for collaboration on QlikView Scripting.

Announcements
QlikView Fans! We’d love to hear from you.
Rules, plus terms and conditions, can be found here.
New Contributor II

## Problem with number format

Hello:

I'm having the following problem with number formats:

This is the number with its original format: 123456789

what I need to do is get rid of the last number so it can be like this: 12345678

to do so, i use the following script: If(Len(number)=9,Left(number,8).

The problem is when I have this number: 0123456789

I have to get rid of the last and the first number so I can get: 12345678

Thank you very much!

6 Replies
Valued Contributor III

## Re: Problem with number format

try this:

if(len(num(number)) = 9, left(num(number, 8)))

Esteemed Contributor

## Re: Problem with number format

Hi,

no problem at all. Does the first part work?

You can use another IF_construct to query whether the first digit is a 0 (correct?) and if that's the case, remove the first digit using the MID() function: >>  MID([field], 2, (LEN([field]-1))  <<

HTH

MVP

## Re: Problem with number format

Left(Num(NumberField),8) as NumberField

MVP

## Re: Problem with number format

Try this:

Table1:

Number

0123456789

987654321

];

Best,

Sunny

Esteemed Contributor

## Re: Problem with number format

Hi sunindia,

that's good. I didn't know the num() function does that, although it might be logical ...

Just for the record (I'm a fan of rather extensive documentation so anyone can read my code and understand what it does without running it) - the num() function drops leading zeros, so you don't have to mess with the MID() function and such.

Best regards,

DataNibbler

Valued Contributor

## Re: Problem with number format

hi,  try it

if (len(num(fielname))=9,left(fielname,8),mid(fieldname,2,8))