Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Hi all ,
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
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.
Here you Go.
PFA
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?
Just use 100 - sum(AnswerKey)
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.
tried but its giving wrong result. for 51 its showing 4 remaing
thanks petter
could you please attach the sample ?
In a straight table. Answers and Correct are two fields containing the 100 character strings.
got it thank you which answer I need to correct you or Pankaj both help is highly appreciated
I don't run QlikView at the moment - only Qlik Sense.