Need to extract depends upon Priroity list

Hi Team

Need to extract depends upon Service Launch priority only ( If same TADIG have multiple, select highest one. (5G NSA → LTE → GPRS)

Input:

Output:

Thanks
Shaik

Hi @Mukthar_Valli

=> Use Read Range Workbook


Output → dt_Input
Note: Enable Use Display Format in Properties Panel
=> Use below LINQ in Assign activities:

Assign Activity 1 -> priorityDict = New Dictionary(Of String, Integer) From {
                                  {"5G NSA", 1},
                                  {"LTE", 2},
                                  {"GPRS", 3}}

Assign Activity 2 -> dt_Output = dt_Input.Clone

Assign Activity 3 -> dt_Output = (From g In dt_Input.AsEnumerable()
                               Group g By TADIG = g.Field(Of String)("TADIG") Into Group
                               Let bestRow = Group.OrderBy(Function(r) priorityDict(r.Field(Of String)("Service Launch").Trim())).First()
                               Select bestRow).CopyToDataTable()

Variable Datatype:
The image shows a table with columns labeled "Name," "Variable type," "Scope," and "Default," listing two entries: "priorityDict" as a Dictionary<String,Int32> and "dt_Output" as a DataTable, both within the "Sequence2" scope. (Captioned by AI)

=> Write Range Workbook dt_Output back to excel.

XAML:
Sequence2.xaml (8.8 KB)

Hope it helps!!

3 Likes

Hi @Parvathy

If same TADIG contains high priority list then it will pick all rows only one row?

Input:

I need all high priority list from same TADIG but your code picking only one row

can you update and share please

Thanks
Shaik

Hi @Mukthar_Valli

What’s your expected Output.

Regards

Hi @Parvathy

Input:

Output:

(Note: if Same TADIG have multiple select highest one)

Thanks
Shaik

Hi @Mukthar_Valli

Change the LINQ as below:

dt_Output = (From row In dt_Input.AsEnumerable()
            Group row By TADIG = row.Field(Of String)("TADIG") Into GroupRows = Group
            Let maxPriority = GroupRows.Min(Function(r) priorityDict(r.Field(Of String)("Service Launch").Trim()))
            From r In GroupRows
            Where priorityDict(r.Field(Of String)("Service Launch").Trim()) = maxPriority
            Select r).CopyToDataTable()

Hope it helps!!

Hi @Parvathy

Getting error like , Assign: The given key was not present in the dictionary.

Please check

Thanks
Shaik

Hi @

Assign Activity 1 -> priorityDict = New Dictionary(Of String, Integer) From {
                                  {"5G NSA", 1},
                                  {"LTE", 2},
                                  {"GPRS", 3}}

Assign Activity 2 -> dt_Output = dt_Input.Clone

Assign Activity 3 -> dt_Output =  (From row In dt_Input.AsEnumerable()
                                  Group row By TADIG = row.Field(Of String)("TADIG") Into GroupRows = Group
                                  Let maxPriority = GroupRows.Min(Function(r) priorityDict(r.Field(Of String)("Service Launch").Trim()))
                                  From r In GroupRows
                                  Where priorityDict(r.Field(Of String)("Service Launch").Trim()) = maxPriority
                                  Select r).CopyToDataTable()

Check the workflow for better understanding.
Sequence2.xaml (9.3 KB)

Hope it helps!!

@Parvathy

getting same error please help

Hi @Mukthar_Valli

Can you share your workflow, I will help you out with that.

Regards

Hi @Parvathy

Please check below screenshot

Hi @Mukthar_Valli

Did you change PriorityDict by any chance.

Regards

You source data may contains some extra Services that does not exists in you defined dictionary, in this case you have to define the priority of all the Services in the dictionary first.

@Parvathy not changed I just copy code from your workflow and paste but it’s getting same error

Hi @Mukthar_Valli

The same code is working fine at my end, can you share the xaml so that I can resolve.

Regards

Hi @Parvathy

TADIG.xaml (6.9 KB)

Please attached workflow

Hi @Mukthar_Valli

The workflow you have sent works fine at my end, can you please send the excel you’re working with, I will check with that.

Regards

Hi @Parvathy

Please check attached input file

TADIG.xlsx (8.9 KB)

Hi @Mukthar_Valli

Just give all your Service Launch names in priorityDict according to your Priority and try running the code. It should work.

priorityDict = New Dictionary(Of String, Integer) From {
               {"5G NSA", 1},
	           {"VoLTE", 2},
               {"LTE", 3},
               {"GPRS", 4}
}

I have added VoLTE at Priority 2 change according to yours.

Regards