Need to find the index

Hi team.

I have a table as below and i need to get the index of the group

Code value amount
1 abc 112
1 abc 112
1 abc 112
2 cde 123
2 cde 123
2 cde 123
4 rrr 123
4 rrr 123

I need to get the first index value for abc which will be 0 and the last index will 2 same way for cde first will be 3 and the lat will be 5 .
Please suggest how to achieve this

Thanks

Hi team,

Any update on below query

There are many options to do it. Also it was not specified in which target form you need it

One of many options
Assign Activity:
dictLK = Dictionary (Of String, int32() ) =

(From d In dtData.AsEnumerable
Group d By k=d("Code").toString.Trim Into grp=Group
Let gi = grp.Select(Function (x) x.Table.Rows.IndexOf(x)).toArray
Select t=Tuple.Create(k,gi)).ToDictionary(Function (t) t.Item1,Function (t) t.Item2)

so you can access e.g. first code first index by
dictLK(“1”).First()
etc…

Thanks for the reply, I am. Getting an error as dictionary is not a member of tuple (of string, integer())

I have assign dictLk variable as dictionary< string, int32>

Please let me know where i made a mistake

we fixed a small issue - missing )

Just to visualize it:
grafik
kindly note: we configured an int32 Array

grafik

Find some starter help here:
ppr_dictLK_GroupIndex.xaml (9.9 KB)

Thank you … I have a doubt in assign directly shall we take the unique value and get the respective index value

Like assign dictLk(“”) Inside ()we need to pass the unique code value or how can achieve this

yes we would use the key to get back the array with the row indexes as shown above:
dictLK(“1”)

Getting all keys from the dictionary we can do:
dictLK.Keys

Also have a look here:

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.