Sure @Aleksi you may find alternative or better way, but this is what I do.
Not horiffically complicated, but it is a bit complex actually.
Preparation and Assumption
[EnumList] — User pick up multiple or sole item out of the list. Usual Enum list type field.
[Enum] — Enum type. This fields will generate the dropdown list of of [EnumList], and user select single value. We will find the index number of the selected item out of the [Enumlist] as above.
Sample for instance
EnumList hold {Apple Juice, Apple Cake, Apple, Apple Computer}> Enum ; I select “Apple”
–
(1) Add virtual column with name something like [add @ to enumlist]
Push and expression like this
“@”&Substitute(text([EnumList])," , “,”@,@“)&”@"
This expression will convert the Enumlist filed onto text type first, then add @ to both beginning and end of “EACH” enum items. This expression should yeild something like
@Apple Juice@, @Apple Cake@, @Apple@, @Apple Computer@- It is not bold, but this post convert to bold…
As you can see, now each enum list item is “Wrapped” by @ mark
–
(2) Add another virtual column [Add @ to enum]
Expression is
Similarly, we wrap enum value (selected value) by @
@&[Enum]&@
(3) Add another VC with Index Number
Expression required here is
COUNT(> SPLIT(> LEFT([add @ to Enumlist],> FIND( [add @ to Enum] , [add @ Enumlist])+LEN([add @ to Enum])-1> ),> “,”> )> )
This expresion will give us the index number of selected item basis “full match” the value.
If enumlist item contain the string as apart, it will not take account, but just see and find the index number where the selected enum value full match with the item value.
In case we have duplicate in the enum item, then it should return the first and earliest index number counting from 1.
–
Trick behind here is to convert the enumlist item as well as selected enum item by adding arbitrary value. In this demo case, I used the string / text of @, but we are able to involve any arbtrary text.
–
I select “Apple” on enum selection which will be returned as
@Apple@
then we will find the index number which perfectly match from
@Apple Juice@, @Apple Cake@, @Apple@, @Apple Computer@
Then return the index number.
First valid test ; @Apple Juice@,
Does not match with @Apple@
Go next and next.
This case, index number expression will return 3, as it is fully match.