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

Announcements
Want to see what's currently in public preview? We've pulled it all together in one place. Check it out here
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Count digit thru expression

How can I write this thru expression?

if 'number' has 4 digit, copy 'number'

if 'number' is not 4 digit, copy 'Loc' that is 4 digit else nul()

Number                    Loc                 Desired result

0021                         AU                       0021

35697                       NZ                         -

PH                           1234                    1234

1 Solution

Accepted Solutions
rwunderlich
MVP
MVP

if(len(Number) = 4 and IsNum(Number), Number,

if(len(Loc) = 4 and IsNum(Loc), Loc

Null()))


-Rob

View solution in original post

3 Replies
rwunderlich
MVP
MVP

if(len(Number) = 4 and IsNum(Number), Number,

if(len(Loc) = 4 and IsNum(Loc), Loc

Null()))


-Rob

Anonymous
Not applicable
Author

Hi Rob,

I'm not sure why but it gives me '-' on all records.

Anonymous
Not applicable
Author

i've already figured it out. the 'Number' field is a string. i converted it to number format and your expression worked! thank you