Skip to main content
Announcements
Accelerate Your Success: Fuel your data and AI journey with the right services, delivered by our experts. Learn More
cancel
Showing results for 
Search instead for 
Did you mean: 
MicSim
Contributor
Contributor

Aggregate and compare text values in two fields

In Qlik Sense (charts only - not load script) I need some help to identify and calculate occurrences for each ID where values in CODE_A does not match the values in CODE_B.

MicSim_0-1706122083912.png

 

Based on data, I want a straight table with a row for each ID and the number of "Errors" like this:
 
MicSim_1-1706122133410.png

 

For each ID It's an error, if the values in CODE_A don't have a match in CODE_B. In this case :
ID 1 is not an error because the value "AA" also is present in CODE_B.
ID 2 has 1 error because "CC" <> "DD"
ID 5 has 2 errors because neither "AA" or "BB" is in CODE_B
ID 6 has 0 errors because value "CC" is in both CODE_A and CODE_B
 
Data:
Load *
Inline [ID, CODE_A, CODE_B
1, AA, AA
1, AA, BB
2, CC, DD
3, EE, EE
3, EE, FF
4, FF, FF
4, FF, GG
5, AA, FF
5, BB, GG
6, CC, DD
6, EE, CC
];
Labels (4)
1 Reply
henrikalmen
Specialist
Specialist

This solution (expression for the Error column) is pretty ugly, but it works for the specific example you have given. But I suspect your actual data to be more complex, so this might not work for you at all.

 

if(wildmatch( concat(CODE_B) , '*'&left( concat(distinct CODE_A) ,2)&'*'), 0, len( concat(distinct CODE_A) )/2)