Skip to main content
Announcements
Live today at 11 AM ET. Get your questions about Qlik Connect answered, or just listen in. SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
fortaleza40
Contributor III
Contributor III

Floor function keeping leading zeros

Hello Community,

In a string field i have some ZIP codes, i had a display issue with this values and i found that if i use the Floor formula the issue is fixed, but now i can see this formula is removing the leading zeros, like for example 01234 it display 1234, how can i use this Floor without removing the zeros?:

Text(Floor([My Field]))

1 Solution

Accepted Solutions
fortaleza40
Contributor III
Contributor III
Author

i found a fix detecting if number, this works fine

if(IsNum([myvalue]),num([myvalue],'00000'),Text([myvalue]))
 
the problem now is that there is not a defined format, the user can enter 8, 88, 0088, any format, how can i define a format or keep the source format?
Hey thanks for your help Dili

View solution in original post

8 Replies
dplr-rn
Partner - Master III
Partner - Master III

if you use floor the leading zeros will disappear.

for zipcode i typically just use - text([My Field])

if that doesnt work... elaborate on the original problem why you used floor?

fortaleza40
Contributor III
Contributor III
Author

Because Qlik is converting the zip codes in Dates, not all but many, i found using Floor inside Text fix the issue but add another issue with the leading zeros, not sure why Qlik do that with zip codes

dplr-rn
Partner - Master III
Partner - Master III

Share some sample data. 

fortaleza40
Contributor III
Contributor III
Author

it is very simple issue, the zip code 33156 is converted to 10/10/1990, i can see in the database the number but qlik sense display the date, if you add floor Qlik display the number, why, i don't know, but only happens with some dates, basically is the same number but in Date format, is a weird issue. i want to tell Qlik, hey not touch the String format, up to know only floor fixed it, there is an alternative to floor?

Why people use floor with Dates, for example: Date(Floor())?

 

 

 

dplr-rn
Partner - Master III
Partner - Master III

people use floor with date to remove timestamps.

you have to look at your data to find the reason. did you try Text(zipcode)?

fortaleza40
Contributor III
Contributor III
Author

yes, it shows dates instead of numbers

 

 

 

 

dplr-rn
Partner - Master III
Partner - Master III

that is weird.

Whats the source?

try this too ''&zipcode either on qlik script or in sql (if db)

Afraid cant help further without access to the full data set. good luck

fortaleza40
Contributor III
Contributor III
Author

i found a fix detecting if number, this works fine

if(IsNum([myvalue]),num([myvalue],'00000'),Text([myvalue]))
 
the problem now is that there is not a defined format, the user can enter 8, 88, 0088, any format, how can i define a format or keep the source format?
Hey thanks for your help Dili