Skip to main content
Solved

Compare two columns (Category and Class) and detect if the Class entered is in the right Category

  • September 18, 2019
  • 10 replies
  • 23 views

Forum|alt.badge.img
  • 16 replies

Hello,

I have two columns Category and Class already filled. I would like to compare and see if the class entered is in the right category.

Example :

Category = 10 / Class = 20, 40, 60

Category = 11 / Class = 20, 21, 22, 23, 24

Category = 12 / Class = 23, 25, 27, 29, 31

 

Category

 

Class

 

RESULT

 

10

 

20

 

True

 

10

 

22

 

False

 

11

 

23

 

True

 

12

 

23

 

True

 

10

 

29

 

False

 

12

 

31

 

True

 

10

 

60

 

True

 

 

Thank you very much in advance for your help.

Best Regards

Best answer by itay

Hi,

There are a number of possibilities, just had @david_r mentions.

I would use an AttributeCreator and conditional values:

Probably can be fancied up by some regex....

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

10 replies

david_r
Celebrity
  • 8394 replies
  • September 18, 2019

One possible solution would be to use an AttributeValueMapper to calculate the correct class based on the category value, then a Tester to compare the correct class with the existing class value.


itay
Supporter
Forum|alt.badge.img+18
  • Supporter
  • 1442 replies
  • Best Answer
  • September 18, 2019

Hi,

There are a number of possibilities, just had @david_r mentions.

I would use an AttributeCreator and conditional values:

Probably can be fancied up by some regex....


Forum|alt.badge.img
  • Author
  • 16 replies
  • September 18, 2019

One possible solution would be to use an AttributeValueMapper to calculate the correct class based on the category value, then a Tester to compare the correct class with the existing class value.

Thank you very much for your answer.

Could you be more specific please?

The problem is that each category has multiple class value and sometimes one class value could be in different categories.


ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3427 replies
  • September 18, 2019

Classes can correctly be in more than one category?


Forum|alt.badge.img
  • Author
  • 16 replies
  • September 18, 2019

Hi,

There are a number of possibilities, just had @david_r mentions.

I would use an AttributeCreator and conditional values:

Probably can be fancied up by some regex....

It works, thank you very much for your answer


takashi
Celebrity
  • 7843 replies
  • September 18, 2019

I would create an external table mapping each Category and comma-separated possible classes like this,

CategoryPossibleClasses1020,40,601120,21,22,23,241223,25,27,29,31

merge an appropriate possible classes to each record using a DatabaseJointer or a FeatureMerger, and then determine if the class is in the possible classes with conditional value setting.


david_r
Celebrity
  • 8394 replies
  • September 18, 2019

Thank you very much for your answer.

Could you be more specific please?

The problem is that each category has multiple class value and sometimes one class value could be in different categories.

Depends on what you consider to be the correct Category for Class = 20? Are both values 10 and 11 correct?


ebygomm
Influencer
Forum|alt.badge.img+44
  • Influencer
  • 3427 replies
  • September 18, 2019

I would create an external table mapping each Category and comma-separated possible classes like this,

CategoryPossibleClasses1020,40,601120,21,22,23,241223,25,27,29,31

merge an appropriate possible classes to each record using a DatabaseJointer or a FeatureMerger, and then determine if the class is in the possible classes with conditional value setting.

This the approach i would take, for ease of maintenance. Although i'm getting an odd result with the In Test

inissue.fmwt

You could also use an AttributeValueMapper to add the possible class values, then do the test. Might be a better option than a FeatureMerger if it the values aren't changing.


itay
Supporter
Forum|alt.badge.img+18
  • Supporter
  • 1442 replies
  • September 18, 2019

It works, thank you very much for your answer

Glad I could help.


takashi
Celebrity
  • 7843 replies
  • September 19, 2019

This the approach i would take, for ease of maintenance. Although i'm getting an odd result with the In Test

inissue.fmwt

You could also use an AttributeValueMapper to add the possible class values, then do the test. Might be a better option than a FeatureMerger if it the values aren't changing.

Hi @egomm, I was able to reproduce the odd behavior. I suspect that there is a potential bug regarding the IN operator, Comparison Mode, or somewhere. I reported the issue to Safe support already, and they filed a problem report.

In the interim, you can get correct result if you set a string mode (Case Sensitive or Case Insensitive) to the Comparison Mode parameter in the Tester.