Skip to main content
Announcements
Qlik Connect 2024! Seize endless possibilities! LEARN MORE
cancel
Showing results for 
Search instead for 
Did you mean: 
jonesbrown
Creator
Creator

What is KeepChar and PurgeChar  give me an example

Hi All,

I am new to Qlikview 

What is KeepChar and PurgeChar  give me an example 

plz help.

Labels (1)
3 Replies
msKarthikeyan
Employee
Employee

Keep char and purge char take two strings as input..
Keepchar(string1 , string2) -- Returns the characters in string1 which appears in string2 ..

Keepchar(qlik1234, 12) returns 12 as 1&2 are the characters that are part of qlik1234..
Keepchar(qlik1234, 125) returns 12 as 1&2 are the characters that are part of qlik1234 and 5 is not present in qlik1234..
Keepchar(qlik12234, 12) returns 122 as 1&2 are the characters that are part of qlik12234 and multiple characters are returned multiple times..
Keepchar(qlik1223411, 12) returns 12211 as 1&2 are the characters that are part of qlik12234 and multiple characters are returned multiple times and the characters are returned in the same order of appearance..


purgechar is the oppostite of keepchar.. it returns the characters that are not present in the second string
Purgechar(qlik1234, 12) returns qlik34 as q,l,i,k,3&4 are the characters that are not part of 12..
Purgechar(qlik1234, 125) returns qlik34 as q,l,i,k,3&4 are the characters that are not part of 125..
Purgechar(qlik12234115, 12) returns qlik345 as q,l,i,k,3,4&5 are the characters that are not part of 125 and the characters are returned in the same order of appearance..

Hope your doubt is cleared.
Vegar
MVP
MVP

You got a good thorough answer from @msKarthikeyan . I just want to point out that  both parsmeters in the the functions are strings (text) you should use single quotations even hard coding the parameters like this:

Keepchar( 'qlik1234', '1q2' ) 

And

Purgechar( 'qlik1234', '1q2' )  

 

When comparing a field to string you do like this

Load

KeepChar(FieldName, '1q2' ) as Kept,

KeepChar(FieldName, '1q2' ) as Purged,

Amount

Inline [

FieldName, Amount

qlik123, 3

Join234, 1

]

Brett_Bleess
Former Employee
Former Employee

Please be sure you close out your thread by using the Accept as Solution button on the post(s) that got you the information you needed, this gives credit to the posters and lets the other Members know what helped.  Please be sure to circle back and complete this to properly close things out.

Regards,
Brett

To help users find verified answers, please do not forget to use the "Accept as Solution" button on any post(s) that helped you resolve your problem or question.
I now work a compressed schedule, Tuesday, Wednesday and Thursday, so those will be the days I will reply to any follow-up posts.