Jump to content
Server Maintenance This Week. ×

Trick to find the value position in a list for a given string


This topic is 3202 days old. Please don't post here. Open a new topic instead.

Recommended Posts

Hi

Here is the function which will give the value position in a list.

 

ValueCount ( Left ( $ItemList ;Position (  "¶"& $ItemList & "¶" ; "¶" & $SearchString & "¶" ; 1 ; 1 )  + Length ( $SearchString ))  )

 

Example,

$ItemList = "1¶2¶14¶5¶222¶12¶22¶42¶11¶23¶44"

$SearchString = "22"

 

Result = 7

Link to comment
Share on other sites

Here is the function which will give the value position in a list.ValueCount ( Left ( $ItemList ;Position (  "¶"& $ItemList & "¶" ; "¶" & $SearchString & "¶" ; 1 ; 1 )  + Length ( $SearchString ))  )

Present the calculation with generic argument names rather than $variables and it becomes a handy Custom Function:

ItemIndexPositionInList ( theItem ; theList ) =

ValueCount ( Left ( theList ; Position ( ¶ & theList & ¶ ; ¶ & theItem & ¶ ; 1 ; 1 ) ) )

Link to comment
Share on other sites

This topic is 3202 days old. Please don't post here. Open a new topic instead.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.