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

Announcements
Save $650 on Qlik Connect, Dec 1 - 7, our lowest price of the year. Register with code CYBERWEEK: Register
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Purge string

Hi,

some of my account numbers comes with seven zeroes in fornt, need to get rid of them, example below:

000000088899

0000000777111

00000003334

000000066666

should be presented as:

88899

777111

3334

66666

what would be the easiest way to remove these zeroes in the script?

25 Replies
Not applicable
Author

Hi KN,

not sure how to implement it into my script.

Can you pls give me a hint?

//O


jagan
Partner - Champion III
Partner - Champion III

Hi,

The below script works fine

Load value,Num(value) as Value1;

Load * Inline [

value

000000088899

0000000777111

00000003334

000000066666

];

Please check.

Regards,

Jagan.

Not applicable
Author

You can use this formula:

Num(PurgeChar(Text(FieldName), '0'), '000')

richnorris
Creator II
Creator II

When you get leading zero's like that, it tends to be because Qlikview is interperating the field as a string. This tends to happen if there is leading or trailing whitespace, but also happens sometimes when one or more rows contain string data. So, my first port of call would be to do a trim(), so maybe try:

=trim(num(num#(val)))


If you're still having trouble, I'd check the rest of your data, and make sure you don't have any fields in there that are obviously text.

Kushal_Chawda

Try,

Purgechar(YourField,'0') as NewField

Not applicable
Author

Hi

Please find the attached application, i solved with the help string functions

Regards

AR UMAMAHESH

Not applicable
Author

Purgechar some times not good

suppose if the number have zero between the other numbers, purgechar will remove that one also

kavita25
Partner - Specialist
Partner - Specialist

Hi,

try this

REPLACE

(LTRIM(REPLACE(Field_name, '0', ' ')), ' ', '0')

Regards,

Kavita

qlikviewwizard
Master II
Master II

Hi,

Please use this.

Data:

Load *,

Purgechar(FIELD_Zero,'0') as FIELD_NoZero;

LOAD * INLINE [

FIELD_Zero

000000088899

0000000777111

00000003334

000000066666

];

EXIT Script;

Capture.JPG

Not applicable
Author

This is the logic i implemented

Temp:

LOAD * INLINE [

    Phone

    000000088899

    0000000777111

    00000003334

    000000066666

];

   

Final:

LOAD LTrim(Replace(Phone,'0000000','')) as PhoneNumber

Resident Temp;