Swap Data on the Basis of Priority

Hello Everyone
Can anyone here help me please?
Here is the Excel File
Sample Data (Input & Output).xlsx (14.0 KB)

Problem Statement:
In Given Input Data table I need to swap the OTN No_ Month Wise on the basis of some Priority parameters which is as follow

For Choosing the OTN No.–>
1.Top Priority_1
(X >>> Y) It Means we have to assign X first the Y .
2.Top Priority_2
(BO > OOS > EX > MTO ): It means we have to select the ‘BO’ first then OOS and so on.

3.Top Priority_2
(DES > STO > BRN > LOO > EXP > FIN > RAM > RED ): DES is prior then STO And so on.

(Feb-2022 > Mar-2022 > Apr-2022 > Nov-2022)

  1. Priority
    1 > 2 > 5 ( 1 is most prior And 5 is least.)

  2. Remaining Work is only for “Stage: LOO to LOO”(Swap).

  3. “Count” means Unique Rows on the basis of these 4 columns “Top Priority_1, Top Priority_2, Month, Priority”.

For an Example Selecting an OTN_no. the Process will be In Top Priority_1 we need to choose the ‘X’ First the in and then for Top Priority_2 we have to select ‘BO’
and then stage DES will be first priority after that we have to choose the first Month in the list like if there are ‘Jan’, ‘Feb’, ‘March’ the we will go for ‘Jan’
after selecting the month priority should be considered as ‘1’ is more prior then ‘2’.

How To Swap the OTN No.

After Choosing the Input OTN_No. according to that OTN No. information we will choose the OTN_No. on the Priority Parameters Like:

1.In priority bases Top Priority_1 and Top Priority_2 will be the same as how we have chosen the OTN_No.
2. Then for stage :
Priority will be ( RED > RAM > FIN > EXP > LOO > BRN > STO > DES )
3.For Month the:
(Nov-2022 > Apr-2022 > Mar-2022 > Feb-2022)
4. Priority goes like 5 > 2 > 1 like we will choose the least Prior Fist and 5 is least prior the 2 and 1.

Note: In the Output Data of excel file some OTN_No. are written same as Swap OTN_No. because some OTN_No. will not be swapped on the Priority parameters which we have to consider.

1 Like

Hey @Mayank_Soni

This can be done using Excel and datatable manipulations

Are you still facing issue with this ?


I want use LINQ to solve this. Can You please help me with the same.


Swapping sound like sorting?

Maybe these custom sort approaches will help ypou for the solution development: