cancel
Showing results for 
Search instead for 
Did you mean: 

Re: cannot get a correct scores for postal codes by countries

Former Member
0 Kudos

There are multiple country codes in a customer address table. I tried to calculate the score for postal codes of different countries. The rule is as

BEGIN

   IF ($ctryCode='US')

   BEGIN

       IF (match_regex($postalCode, '^\d{5}(-\d{4})?$')) RETURN TRUE;

       ELSE RETURN FALSE;

       END

   ELSE RETURN FALSE;

END

The script works in IBM Information Analyzer. I tested the rule in Data Insight successfully, but it seems that the result of Calculate Score is not correct, which gives the score for all countries, which is much lower than the score of US postal codes. Is there something wrong? Or should I setup something?

Appreciate for suggestions!

Accepted Solutions (1)

Accepted Solutions (1)

former_member187605
Active Contributor
0 Kudos

It's obvious IS returns the score for all countries, because it applies the rule to all records.

You can work around the issue by defining a view with $ctryCode='US' and apply the rule to the view.

Answers (1)

Answers (1)

adrian_storen
Active Participant
0 Kudos

When you use an IF statement as part of the rule then ALL data in the table you bind will be assessed.  You have two options.

1.  As Dirk suggested, you filter in a new DI/ database view

2.  You add the country code as a filter and exclude from the rule score