Qlik Community

New to QlikView

Discussion board where members can get started with QlikView.

soniasweety
Contributor III

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

Tags (2)
1 Solution

Accepted Solutions
MVP
MVP

Re: Count matching characters

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.

11 Replies
passionate
Valued Contributor

Re: Count matching characters

Here you Go.

PFA

soniasweety
Contributor III

Re: Count matching characters

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
Valued Contributor

Re: Count matching characters

Just use 100 - sum(AnswerKey)

MVP
MVP

Re: Count matching characters

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

Re: Count matching characters

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

soniasweety
Contributor III

Re: Count matching characters

thanks petter

could you please attach the sample ?

MVP
MVP

Re: Count matching characters

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

soniasweety
Contributor III

Re: Count matching characters

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

MVP
MVP

Re: Count matching characters

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

Community Browser