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: 
new_guy
Contributor III
Contributor III

KeepChar and length

Hey Guys,

I need a little help with the keepChar and length functions. I have an if function with 2 conditions using these functions.

if(
            	KeepChar("Number",0123456789)
            	and
                len("Number")=12
                ,KeepChar("Number",0123456789)
            	)								  AS Number(this should be a KEY_VALUE)
 

 The Problem is that the extracted number-data contains of numbers with spaces e.g. 123 456 789 123. So in total I have 12 digits but with spaces I have a length of 15 not 12. Any suggestions how to transform this data into something which should be seen under "Number" with a 12 digit number without spaces?

 

2 Replies
OmarBenSalem

if(
            	KeepChar(Replace("Number",' ',''),0123456789)
            	and
                len("Number")=12
                ,KeepChar(Replace("Number",' ',''),0123456789) )
sunny_talwar

Are you looking for this may be?

If(
   Len(KeepChar("Number",0123456789)) = 12,
   KeepChar("Number", 0123456789)
) as Number