Skip to main content

I have a set of records (360 total) that are already assigned a relational ID to 3 other records (2 sets of 144 records, and 1 set of 72) I want to group the records in sets of 12 to assigning a _group_index and then start over again for the next relational ID.

For Example:

The first 144 records would already have the same relational ID (Let's say A). In relational set A, the first 12 records would receive a _group_index of 0, records 13-24 would receive a _group_index of 1, all the way through records 133-144 receiving a _group_index of 11. This is the end of relational set A, so relational set B would begin and contain 144 records as well. I would like the _group_index to start over and the first 12 records of relational set B (records 145-156) would receive a _group_index of 0. The number of records in each relational set is not always the same, but they are always a factor of 12. Relational set C in this example is a total of 72 records, so its first 12 records (records 289-300) would receive a _group_index of 0.

Hi @dane_stephenson

 

Would the ModuloCounter transformer work for you?

 

 

Or perhaps using adjacant features to count, and when it gets to 12 assign a new id value.

Hi @dane_stephenson

 

Would the ModuloCounter transformer work for you?

 

 

Or perhaps using adjacant features to count, and when it gets to 12 assign a new id value.
I do not think that the ModuloCounter will work in this case because I need the first 12 to receive the same value (0) and then the next 12 to receive the same value (1), etc. in sets of 12 until we reach the end of that relational group and then start over again at 0.

 

 

As for the Adjacent Features parameter of the Attribute Manager, I am not exactly sure how I would go about implementing the above using that option.

 

 


Hi @dane_stephenson, if I understand the requirement correctly, this arithmetic expression returns your desired group index. Assuming the attribute "_count" stores sequential number starting with 0.

@int(@Value(_count) % 144 / 12)

a part of result table:

0684Q00000ArLdnQAF.png


Hi @dane_stephenson, if I understand the requirement correctly, this arithmetic expression returns your desired group index. Assuming the attribute "_count" stores sequential number starting with 0.

@int(@Value(_count) % 144 / 12)

a part of result table:

0684Q00000ArLdnQAF.png

@takashi This is helpful, but the number of records in a relational set is not always 144.  In the example I gave, there were three relational sets in the total 360 records, two with 144 records and 1 with 72.  They can range from 72 to 864 records in a set.  They are however, always a multiple of 12.

Hi @dane_stephenson, if I understand the requirement correctly, this arithmetic expression returns your desired group index. Assuming the attribute "_count" stores sequential number starting with 0.

@int(@Value(_count) % 144 / 12)

a part of result table:

0684Q00000ArLdnQAF.png

Do the records have a common attribute that can be used to identify each relational set?

 

If they have such an attribute, you can set it to the Counter Name parameter in a Counter to generate sequential numbers starting with 0 for each set. You can then calculate group index with the expression "@int(@Value(_count)/12)".

 

 


Do the records have a common attribute that can be used to identify each relational set?

 

If they have such an attribute, you can set it to the Counter Name parameter in a Counter to generate sequential numbers starting with 0 for each set. You can then calculate group index with the expression "@int(@Value(_count)/12)".

 

 

Yes, they do. Regardless of whether the relational set is 72, 144, or 864 records, they all have the same CABLEIDFKEY value. I will give this suggestion a go and get back to you.

 

 


I think what you need here is a combination of Counter and ModuloCounter.

  • Set a Counter with the Counter Name set to the ID attribute
  • Set a ModuloCounter to count in groups of 12
  • Add an AttributeManager/ExpressionEvaluator to subtract the Modulo count value from the Count value

This will give you the group value that you need. The only drawback you have is that the values will not be 1,2,3,4. They will be 1,13,25,37,etc. But it will be unique and I am sure there must be a way to renumber those to a sequential count.

The Count-Modulo concept is something I often find useful and it is certainly worth being aware of.

Hope this helps.


I think what you need here is a combination of Counter and ModuloCounter.

  • Set a Counter with the Counter Name set to the ID attribute
  • Set a ModuloCounter to count in groups of 12
  • Add an AttributeManager/ExpressionEvaluator to subtract the Modulo count value from the Count value

This will give you the group value that you need. The only drawback you have is that the values will not be 1,2,3,4. They will be 1,13,25,37,etc. But it will be unique and I am sure there must be a way to renumber those to a sequential count.

The Count-Modulo concept is something I often find useful and it is certainly worth being aware of.

Hope this helps.

@Mark2AtSafe I ended up following @takashi advice above. I added a Counter with the Counter Name pointed at the unique relational ID I spoke of. I then added an AttributeManager field that calculated a new value with the following @int(@Value(_FPT)/12) where _FTP is the Output Attribute from the Counter. This gave me groups of 12 assigned with each record being assigned a value of 0, then 1, etc. Because I needed the grouping to begin at 1 and not 0, I then added another field that calculated a value with the following @add(@int(@Value(R_group_index)),1) where R_group_index is the grouping index created previously. This got the job done. It handles any number of relational groups and with any multiple of 12 records within that relational group.

Reply