Having a Enumlist/List type column with my app. For instance, the detail view is showing like this.
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.
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.
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 ; -