Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all,
I have a problem to calculate the length of a numeric field with leading zeros.
My field comes from a MySQL database and has values like these:
Number
000
1
39
001301
I need to calculate the length of Number in the script and I want to count the zeros too.
I want this result:
Number Length_Number
000 3
1 1
39 2
001301 6
I tried to use in the script
load *,
len(Number) as Length_Number ;
sql select Number
from table;
but it results:
Number Length_Number
000 1
000 2
000 3
000 4
.......
000 13
1 1
39 2
39 4
001301 6
001301 8
and so on.
I tried to use
load *;
sql select Number,
char_length(Number) as Length_Number;
from table;
and I had the same result.
Can someone help me? Thanks.
Just noticed that zeros should also count, so my answers are incorrect ...
hi,
did you ever find a solution for your leading zero issue?
thx
br
chris
One solution is.
Len('x'&01007)-1
Check the below post.
https://community.qlik.com/t5/Qlik-Sense-App-Development/leading-zero-using-Len/m-p/1724305/