Skip to main content
Announcements
Have questions about Qlik Connect? Join us live on April 10th, at 11 AM ET: SIGN UP NOW
cancel
Showing results for 
Search instead for 
Did you mean: 
soniasweety
Master
Master

Count matching characters

Hi all ,

Sunny Talwar

Petter Skjolden

I need to count the matching characters in a field value

example:  one exam  100 questions are there   I have written 100 answers   like

ABCACDAABC............  like 100

for this  key also avaialbe in second table   like

ABBBBCCCCC      so  my answer and key  to match and check how many correct or wrong by letter by letter

in this   ABCACDAABC --my answers   

             | | \ \ | | | \ \ \ \                 in this example  - 3 is correct answer count  7 is wrong count

           ABBBBCCCCC      -- key       so First letter A-A   1st answer correct so count 1   [so how many correct answers that count and wrong count]

B-B correct  so like that correct answer count and wrong answer count

1 Solution

Accepted Solutions
petter
Partner - Champion III
Partner - Champion III

For the number of correct answers:

SubstringCount(Concat(Mid(Answers,ValueLoop(1,100),1)=Mid(Correct,ValueLoop(1,100),1),'', ValueLoop(1,100)),'1')

For the number of incorrect answers:

SubstringCount(Concat(Mid(Answers,ValueLoop(1,100),1)=Mid(Correct,ValueLoop(1,100),1),'', ValueLoop(1,100)),'0')

These are expressions that must be used in a straight table and not in the load script.

View solution in original post

11 Replies
passionate
Specialist
Specialist

Here you Go.

PFA

soniasweety
Master
Master
Author

thanks for your response   I feel its correct but I need to check with data

so now am getting the sum of answerkey as 51 fro 00036199  

now I want to show remaining 49  in other column    so how can I get?

passionate
Specialist
Specialist

Just use 100 - sum(AnswerKey)

petter
Partner - Champion III
Partner - Champion III

For the number of correct answers:

SubstringCount(Concat(Mid(Answers,ValueLoop(1,100),1)=Mid(Correct,ValueLoop(1,100),1),'', ValueLoop(1,100)),'1')

For the number of incorrect answers:

SubstringCount(Concat(Mid(Answers,ValueLoop(1,100),1)=Mid(Correct,ValueLoop(1,100),1),'', ValueLoop(1,100)),'0')

These are expressions that must be used in a straight table and not in the load script.

soniasweety
Master
Master
Author

tried but its giving wrong  result.  for 51  its showing 4  remaing

soniasweety
Master
Master
Author

thanks petter

could you please attach the sample ?

petter
Partner - Champion III
Partner - Champion III

In a straight table. Answers and Correct are two fields containing the 100 character strings.

soniasweety
Master
Master
Author

got it thank you     which answer I need to correct   you or Pankaj   both help is highly appreciated

petter
Partner - Champion III
Partner - Champion III

I don't run QlikView at the moment - only Qlik Sense.