Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

Comparison of string in Qlikview

Hi All,

Can any one tell how to compare two strings and provide the count based on matching?

For Example:

String are:

South Africa

South Afri

Count is 10(including space)

1 Solution

Accepted Solutions
jagan
Luminary Alumni
Luminary Alumni

Hi,

Please find attached file for solution, used macro to solve this.

Regards,

Jagan.

View solution in original post

11 Replies
jagan
Luminary Alumni
Luminary Alumni

Hi,

If('South Africa' = 'South Afri', 'Match', 'Not Match')

Len() is used to find the length of the string.

Regards,

Jagan.

tresesco
MVP
MVP

This?

If(left('South Africa', Len('South Afri')) = 'South Afri', Len('South Afri' ))   // here you can replace the strings accordingly

If not this, plesae expain a bit more.

Not applicable
Author

Thanks Jehan,

But i want to compare two column of data which are having string data and give the count value for each row of data

Not applicable
Author

My input are like as follows:

String1String2
Samsung Samsun
ChinaChinna

I want to get the count based on number of characters are matching.

like  as follows:

String1String2Count
Samsung Samsun 6
ChinaChinna4
tresesco
MVP
MVP

That means you need to some function which would give the first mismatch chracter position. QV doest not have a function for that. I guess you can try creating a vb function and call that in the script.

jfkinspari
Partner - Specialist
Partner - Specialist

If the length of the fields are relatively small, you you could make embedded if formulas comparing the first character in first level if, two characters in second level if .. undtil you reach the maximum string size.

Not pretty - but it might be a solution.

jagan
Luminary Alumni
Luminary Alumni

Hi,

Please find attached file for solution, used macro to solve this.

Regards,

Jagan.

tresesco
MVP
MVP

Hello,

I have created a function in VB and implemented that during load. Happy to try it and achieving.

Hope it helps.

PFA

Not applicable
Author

use this expression in your script 

If(left(String1, Len(String2)) = String2, Len(String2 )) As Count