Generally it could cause matching-errors if you matched like If(... = 'NA', ... but in your case it seems that the country code is separated by a space, so you could use If(... = 'NA ', ... or If(... = ' NA', ... whereas I would rather use a pick(wildmatch()) function instead a nested if-loop.
But a better way is to use a mapping-table and applymap() - have a look here: http://community.qlik.com/blogs/qlikviewdesignblog/2012/09/18/one-favorite-function-applymap
See the attached. I tokenise the product names using subfield() and then do an applymap to match the tokens to the country codes, using ZZ as a default for no match. Then I get the min string value for the serial no (or Other if it is ZZ).
This will work reasonably well if you have a small set of countries. If you have many (eg the full ISO 3166 list) then the error rate will go up, as almost any 2 char token will match something (eg NA matches Namibia; BI matches Burundi).
Country Mapping.qvw 134.8 K