Skip to main content
Announcements
Introducing Qlik Answers: A plug-and-play, Generative AI powered RAG solution. READ ALL ABOUT IT!
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
Partner Ambassador/MVP
Partner Ambassador/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
Partner Ambassador/MVP
Partner Ambassador/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