How to get the "index" number out of the given LIST

Having a Enumlist/List type column with my app. For instance, the detail view is showing like this.

[Enumlist]
Z , A , O, S , E , B

Translate those value to expressoin under the Appsheet, which could return like this.

List(Z , A , O, S , E , B)

In Appsheet, each enumlist/list carriers own/unique index, which represent where each value is reside within the given list. For instance, this sample list, Z is index 1, A is index 2, and so on.
We have INDEX() expression which extract the value of given Index, but we dont have (at least for now) the expression to do the operation to get the index number by giving the list value.
For instance, we give text valoue of โ€œSโ€ then expression returns number โ€œ4โ€, as the index for S value in the list of List(Z , A , O, S , E , B) is 4th.

To achieve this calculation, this chain of expression will do the job.

COUNT(
SPLIT(
LEFT(TEXT([EnumList]),
FIND( TEXT([Enum]) , TEXT([EnumList]))+LEN(TEXT([Enum]))
),
" , "
)
)

[EnumList] โ€” either list or enumlist data type field.
[Enum] โ€“ Field to pick up ONE value of the [EnumList]

Expression first to โ€œstringifyโ€ the given list, leaving comma โ€œ,โ€ between the eumm item. Then find which position of text the given Enum is going to start from. Once we get the number of the starting position, then we add the lenght of the text of Enum itself.
As a result, it returns โ€œnumberโ€ value, wihch represents the lengh of the strigfiied texts, ending wiht the last character of the given Enum. In other words, any items including comma โ€œafterโ€ the selected text/enum will be removed by using LEFT expression.

Now we have stringified texts, and each enum are separated by " , " comma.
We split this stringified text back to EUMMLIST/LIST style, and then count how many list items are left as a result. The selected enum value are always sitting at the end of the list, i.e. upper right, in other wise, at the end of the list.
The count, i.e the length of the enum list are representing where the selected value/enum does resides.

Create the list (enumlist) with the natural order, then we offen sort/orderby a certain conditions.
Then give the sorted/reordered enumlist/list to the expression, then it returns the new index based on sorting order.

There are bunch of use cases with this.

I thanks to @Suvrutt_Gurjar who gave me a hint to come up with the expression.

[CAUTION]
Make sure to use this expression with enum list where each item are text value rather than numeric number.
for instance, list with numberic number alone and/or even mixture wth text will work property.

1, a, b, z, s, t, 12, 100, ab, s ----- > does not work. (mixture of text and number)
1, 200,2, 11 ----- โ†’ does not work (number only)

โ€“
This thread is digesting / summarizing the post of ; -

8 1 1,692
1 REPLY 1

MultiTech
Participant V

Manโ€ฆ so this post is another post answering the same thing someone else already answeredโ€ฆ and I just answered it again.


No wonder people in the community are always asking the same questions, if I didnโ€™t see it when I was making my post - how would people who arenโ€™t paying attention see it.

I think thereโ€™s a fundamental flaw with this community software solution; people canโ€™t seem to find the answers that are already out there - even when thereโ€™s two dedicated posts answering that question. (Now three since I didnโ€™t see either of these two posts while I was posting.)

Top Labels in this Space