Jump to content
Server Maintenance This Week. ×

Get specified values


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

Recommended Posts

I am looking for a custom function that will get values based upon a list of value numbers.

 

Example:

 

Data = a¶b¶c¶d¶e¶f¶g

Value Numbers = 3¶5¶6

 

Result should be = c¶e¶f

 

Or if I can choose my own separator, that would be great.

 

Any help I can get would be greatly appreciated.

Link to comment
Share on other sites

/*
GetValues ( listOfValues ; listOfNumbers )
*/


Let([
$i = $i + 1;
v = GetValue ( listOfValues ; GetValue ( listOfNumbers  ; $i  ) )
];
Case(
$i ≤ ValueCount ( listOfNumbers ) ; List ( v ; GetValues ( listOfValues ; listOfNumbers ) );
Let ( $i = "" ; "" )
)
)
  • Like 1
Link to comment
Share on other sites

Try something like:

 

GetValues ( listOfValues ; valueNumbers ) =

Let (
countValues = ValueCount ( valueNumbers )
;
GetValue ( listOfValues ; GetValue ( valueNumbers ; 1 ) )
&
Case ( countValues > 1 ; ¶ & GetValues ( listOfValues ; RightValues ( valueNumbers ; countValues - 1 ) ) )
)

To use your own separator, just substitute it with ¶ when calling the function, then reverse the substitution on the result.

  • Like 1
Link to comment
Share on other sites

This topic is 3902 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.