Find the index of an item in a repeating group

This seems like it should be pretty simple but I can’t figure it out.

I’m trying to find the index of a specific item in a repeating group.

The logic would be as follows:

  • Data type of ‘Things’ with a fields called ‘Name’ (text) and ‘Count’ (number)
  • Repeating group with a content type of ‘Things’
  • For each item in the repeating group, I want to find all Things where Count is the same number as the the current cell’s count and return the index of the first item.

In basic terms, I am ranking the items in the RG and want to show an equal rank where the count is the same.

So for the following table:
Table would be rank 1
House, Horse and Monkey would be rank 2
Fish would be rank 5

I can do a search for Things where the Count is equal to the current item’s count, and I can find the first item, but how do I get its index?

Can anyone point me in the right direction?

Hi Gavin,

There is a tricky way to get what you want to

First, dowload the toolbox plugin in order to use “expression” module
Toolbox

Next, add two expressions in your repeating group cell

  • The first one is used to get previous index

  • Second one is used to calculate ranking
    In your case, ranking is equal to current cell index but, when Count of the previous cell is equal to Count of the current Cell, ranking have to be equal to index of the first cell with same Count.

Finally you get your ranking

3 Likes

In addition, you can also make a relative ranking by using another repeating group

Rank is :

And the final result is

3 Likes

This topic was automatically closed after 70 days. New replies are no longer allowed.