Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
markgraham123
Specialist
Specialist

Tricky conditional sum in Scripting

Hi all,

I'm working on a tricky requirement where:

I have a Primary number and secondary number.

Every number will have a Secondary number.

But for few Primary ID, there exists 2 secondary IDs which resembles that both are same but its corresponding data has to be summed up.

Data:

Primary ID,Secondary ID,A to B,B to C,C to D,Final Transit
12345,55677,211
12345,55677P,12
12345,27865,1367
10908,109566,334
10908,109566P,1
10908,89678,2231
100876,1000555,1660
100876,1000555X0006
145677,167856,229

Please find the application attached

Requirement: For Primary ID 12345, we have Secondary IDs 55677 and 55677P.

For 55677, A to B is 2, B to C is 1, C to D is 1

For 55677P, A to B is 1 and Final Transit is 2.

I'm looking for an output where the corresponding values should be summed up as the Secondary IDs points to same.

OUTPUT:


Primary ID,Secondary ID,A to B,B to C,C to D,Final Transit
12345,55677,3113
12345,27865,1367
10908,109566,3341
10908,89678,2231
100876,1000555,1666
145677,167856,2290



For 55677,

A to B should be 3

B to C should be 1

C to D should be 1 and

Final Transit should be 2.

Any help is highly appreciated. Help Please !!

Message was edited by: Mark Graham

20 Replies
markgraham123
Specialist
Specialist
Author

‌THanq very much for your tim and patience my friend.

i Really appreciate it

I learnt good concepts from u .

you were nailing it.