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

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

eliminating zeros at the start of string

If I had a number with an indefinite amount of zeros proceeding it, how would I get rid of these zeros?

for instance, if this number was 000000000215454854, is there any way qlikview can eliminate these zeros at the start of the number?

I used this code, however it didnt seem to work. Thanks

if(LEFT(TRIM(@1),1)='0',RIGHT(@1,17),

if(LEFT(@1,2)='00',RIGHT(@1,16),

if(LEFT(@1,3)='000',RIGHT(@1,15),

if(LEFT(@1,4)='0000',RIGHT(@1,14),

if(LEFT(@1,5)='00000',RIGHT(@1,13),

if(LEFT(@1,6)='000000',RIGHT(@1,12),

if(LEFT(@1,7)='0000000',RIGHT(@1,11),

if(LEFT(@1,8)='00000000',RIGHT(@1,10),

if(LEFT(@1,9)='000000000',RIGHT(@1,9),

if(LEFT(@1,10)='0000000000',RIGHT(@1,8),

if(LEFT(@1,11)='00000000000',RIGHT(@1, 7),

if(LEFT(@1,12)='000000000000',RIGHT(@1,6),

if(LEFT(@1,13)='0000000000000',RIGHT(@1,5),

if(LEFT(@1,14)='00000000000000',RIGHT(@1,4),

if(LEFT(@1,15)='000000000000000',RIGHT(@1,3))))))))))))))))

15 Replies
SunilChauhan
Champion II
Champion II

or you can use below also

Replece(ltrim(replace(filedname,0,' ')),' ',0)

hope this heelps

Sunil Chauhan
rohit214
Creator III
Creator III

hi

try this

keepchar(filedname,'123456789')

may it helps you

rohit

Not applicable
Author

keepchar(filedname,'123456789') will remove all "0" wherever it appears.

if the field is having "0123" it will return "123"

if the field is having "103" it will return "13"

if the field is having "100" it will return "1"

Not applicable
Author

you can also use the opposite formula. instead of keepchar, purgechar.

purgechar(fieldname, '0')

Not applicable
Author

Generally, all you need is an arithmetic operation and the leading zeros will be dropped. For example, if your input field is named NUMIN, then load it like this:   NUMIN + 0 as NUMOUT      and NUMOUT will not have the leading zeros.

chematos
Specialist II
Specialist II

I´ve just used your method and works perfect. There is a syntax error because you wrote Replece instead Replace, I say that if someone doesn´t realized

Thank´s Sunil, good solution !