Get values from a list when positions are known (using formula)

I want to write a formula that returns the values from the list when positions are known. for eg.

List := A : B : C : D : E : F
Pos := 2 : 4 : 6

Any formulas that could return: B : D : F

I don;t think @Subset would help much here ..
navgupAsked:
Who is Participating?
 
HemanthaKumarConnect With a Mentor Commented:
Zvonko, thanks for filling that up for me. Been in a meeting for 6 hrs.

Navgup, I think I have written it in a manner that you can copy the bottom portion (which is transforming logic) and above line is input line (which I am sure that you will replace it with field values).

Here is the formula that you might want to try.

List := allclasses_disp;
Pos := @Texttonumber(IAClassChoicesIDSel);

digitList := "0" : "1" : "2" : "3" : "4" : "5" : "6" : "7" : "8" : "9";
idList := @text(@texttonumber(@Subset(digitList *+ @subset(digitList; -@elements(digitList)+1); @Elements(List))));
tmpList1 := @Unique(@Replace(List; List; idList));
tmpList2 := @Trim(@Replace(idList; @text(Pos); ""));
List1 := @Replace(tmpList2; idList; List);
@trim(@unique(@Replace(List; List1; "")));
0
 
scottrmaCommented:
Why do you feel that @Subset would not work?
0
 
ArunkumarCommented:
Double @Subsets will work.

First pass the position so that it will return upto the value for example @Subset(List ; Pos) will return A, B for the 2.

Now use the second @Subset on this with value as -1 like

@Subset(@Subset(List ; pos); -1)

This will return B for 2 , D for 4 and F for 6

-Arun.
0
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
ArunkumarCommented:
i got it i got it....

:)
0
 
navgupAuthor Commented:
I ve tried it before.
pos cannot be a list. That is what i found out.
If i use the function you stated, it will only return B, not others. In this case it returns only B

Am i missing something...
0
 
HemanthaKumarCommented:
I have the formula for this.

List := "A" :"B" : "C" : "D" : "E" : "F";
Pos := 2 : 4 : 6;

digitList := "0" : "1" : "2" : "3" : "4" : "5" : "6" : "7" : "8" : "9";
idList := @text(@texttonumber(@Subset(digitList *+ @subset(digitList; -@elements(digitList)+1); @Elements(List))));
tmpList1 := @Unique(@Replace(List; List; idList));
tmpList2 := @Trim(@Replace(idList; @text(Pos); ""));
List1 := @Replace(tmpList2; idList; List);
@trim(@unique(@Replace(List; List1; "")));


If you appreciate it then increase points

~Hemanth
0
 
navgupAuthor Commented:
Thanks Hemanth, but I think there is something very minor wrong in the formula. It is returning all the values in the List.
Pl fix.
0
 
HemanthaKumarCommented:
If you copy and paste the formula then it should give you B;D;F

I have tested and posted it here.  Give me your formula here
0
 
navgupAuthor Commented:
Thanks Hemanth, but I think there is something very minor wrong in the formula. It is returning all the values in the List.
Pl fix.
0
 
navgupAuthor Commented:

List := allclasses_disp;
Pos := @Texttonumber(IAClassChoicesIDSel);

digitList := "0" : "1" : "2" : "3" : "4" : "5" : "6" : "7" : "8" : "9";
numList := @Text(@TextToNumber(digitList *+ digitList *+ digitList) + 1);
idList := @text(@texttonumber(numList; @Elements(List)));
tmpList1 := @Unique(@Replace(List; List; idList));
tmpList2 := @Trim(@Replace(idList; @text(Pos); ""));
List1 := @Replace(tmpList2; idList; List);
@trim(@unique(@Replace(List; List1; "")));


allclasses_disp is a computed text list field and could go upto 1000 values.
IAClassChoiceIDSel is editable text checkbox field with values selected as "2":"6":"8":"15":"99" ...

Now i want whatever value is selected from checkbox to return from allclasses_disp field.
0
 
CRAKCommented:
This calls for the underestimated @Keywords function.
Try this one.... it's tested in an agent!


List := @Explode("A B C D E F"; " ");
Pos := 2 : 4 : 6;

REM "Assume max. 99 entries.";
REM "Construct a list of 99 unique numbers";
Nr10 := @Explode("0 1 2 3 4 5 6 7 8 9"; " ");
Nr99 := @Subset(Nr10 *+ Nr10; -99);

REM "Resize Nr99 to match List\'s lengh";
REM "Prefix the remaining unique numbers to List";
REM "Each elements will then be labelled with its own number:";
REM "01A : 02B : 03C.... ";
NrList := @Subset(Nr99; @Elements(List)) + List;

REM "Now first convert Pos to similar, 2 digit numers in text";
Pos00 := @Left("0" + @Text(Pos); 2);

REM "Construct another list, prefixing Pos00 to each of the elements in List";
PosJoin := Pos00 *+ List;

REM "We now need all elements that occur in both lists";
ResultA := @Keywords(NrList; PosJoin);

REM "Remove all prefixed numbers";
ResultB := @Right(ResultA; 1);

@Prompt([OK]; "Result"; @Implode(ResultB; " : "))


List := @Explode("A B C D E F"; " ");
Pos := 2 : 4 : 6;

REM "Assume max. 99 entries.";
REM "Construct a list of 99 unique numbers";
Nr10 := @Explode("0 1 2 3 4 5 6 7 8 9"; " ");
Nr99 := @Subset(Nr10 *+ Nr10; -99);

REM "Resize Nr99 to match List\'s lengh";
REM "Prefix the remaining unique numbers to List";
REM "Each elements will then be labelled with its own number:";
REM "01A : 02B : 03C.... ";
NrList := @Subset(Nr99; @Elements(List)) + List;

REM "Now first convert Pos to similar, 2 digit numers in text";
Pos00 := @Left("0" + @Text(Pos); 2);

REM "Construct another list, prefixing Pos00 to each of the elements in List";
PosJoin := Pos00 *+ List;

REM "We now need all elements that occur in both lists";
ResultA := @Keywords(NrList; PosJoin);

REM "Remove all prefixed numbers";
ResultB := @Right(ResultA; 1);

@Prompt([OK]; "Result"; @Implode(ResultB; " : "))
0
 
CRAKCommented:
Oops... I must have CTRL + V's twice!
use:
   List:=...
Up to
   @Prompt...
0
 
navgupAuthor Commented:
Hemanth, I think somewhere in the following line of your formula there is a problem. pl verify..

tmpList1 := @Unique(@Replace(List; List; idList));
it is still not working right.

Thanks
0
 
ZvonkoSystems architectCommented:
Hello navgup,

Hemanth's formula works well. You have a typo.

Try this:

List := @Explode(allclasses_disp);
Pos := @TextToNumber(@Explode(IAClassChoicesIDSel));
digitList := "0" : "1" : "2" : "3" : "4" : "5" : "6" : "7" : "8" : "9";
numList := @Text(@TextToNumber(digitList *+ digitList *+ digitList) + 1);
idList := @text(@texttonumber(@Subset(digitList *+ @subset(digitList; -@elements(digitList)+1); @Elements(List))));
tmpList1 := @Unique(@Replace(List; List; idList));
tmpList2 := @Trim(@Replace(idList; @Text(Pos); ""));
List1 := @Replace(tmpList2; idList; List);
@Trim(@Unique(@Replace(List; List1; "")))

And please increase the points for Hemanth at least to 300.

It is really worth :-)

Cheers,
Zvonko

0
 
navgupAuthor Commented:
If i had that many points to spare i would have given it.

Thanks for the input.. i am still working on resolving the typo which i can't find. I ll give credit as soon as i m done.

0
 
ZvonkoSystems architectCommented:
You do not see the typo?

Ok, Hemanth wrote:
idList := @text(@texttonumber(@Subset(digitList *+ @subset(digitList; -@elements(digitList)+1); @Elements(List))));


You wrote:
numList := @Text(@TextToNumber(digitList *+ digitList *+ digitList) + 1);
idList := @text(@texttonumber(numList; @Elements(List)));

Your any reason does this your line not rise a syntax error, I don't know why: (@texttonumber(numList; @Elements(List))

You see the difference?






0
 
navgupAuthor Commented:
Great piece of code. It rocks !
0
All Courses

From novice to tech pro — start learning today.