Skip to main content

Hi there,

I'm having some trouble with performing conditional checks on some shape files I have. Basically, this is what my input looks like:

CityDistrictAA1A2BC

 

C1DE

What I want do do is exclude Cities with blank districts IF they have entries where District is present, but Cities that only have one blank entry should be kept. In this case, I want to keep A1; A2; Bblank; C1; Dblank; and Eblank, whilst removing Ablank and Cblank.

I tried toying with using a tester an making it a composite test, but I have no idea how to use the correct expression.

Thanks in advance,

Robbie

Hi @robbie_botha, a possible way is: if the number of rows belonging to the same city is only one, preserve the feature regardless of its district value, otherwise, preserve the feature only if its district is not empty. To be more specific:

  1. StatisticsCalculator: Count the number of rows belonging to the same city and add the number to corresponding features.
  2. Tester: Filter the features coming from the Complete port of the StatisticsCalculator according to the condition mentioned above.

Hi @takashi,

I don't know if I'm misunderstanding what you're saying, but the problem I have with this solution is that even if I test to preserve all cities with only one entry, how do I specify that cities with multiple entries needs a single specific entry removed? The one that's blank in this case.

Regards,


Hi @takashi,

I don't know if I'm misunderstanding what you're saying, but the problem I have with this solution is that even if I test to preserve all cities with only one entry, how do I specify that cities with multiple entries needs a single specific entry removed? The one that's blank in this case.

Regards,

You should be able to set up a composite test

 

District is empty and _count >1 will route all features to be removed to the passed port for instance

listbuild or aggregator grouped by City.

Test for listelementcount >1 (or count attribute >1)

On count>1 exploder and filter out empty cells. Keep the rest.


Hi @takashi,

I don't know if I'm misunderstanding what you're saying, but the problem I have with this solution is that even if I test to preserve all cities with only one entry, how do I specify that cities with multiple entries needs a single specific entry removed? The one that's blank in this case.

Regards,

This is it.

 

 

 


Thanks @takashi, your solution works perfectly!


Reply