Finding a rolling pair of values in a long list

Roghaltz

New Member
Joined
Nov 26, 2015
Messages
26
Hello all,
I wasn't sure exactly how to describe this problem and I suspect the solution is simple (however, I have been pulling my hair out trying to find it). We have a bunch of salesmen participating in a variety of sales events. We are trying to find the sum of the outputs by pairs of event types on a rolling basis.

There are three main event types (a,b,c in Column B). The first two events in the example below are an "a" and a "b", thus the first pair (and desired output) is "ab" (in column C). Ultimately I would like to sum the output based on the Last 2 Event Types (i.e. ab= ..., ac=..., ba=..., etc). This is easy using sumif once I have the "Last 2 Event Types" in column C.

There can be a different number of salesmen in each event (usually 6-10). The event types occur in pretty much random order.

There many events in column B so I don't want do Last 2 Event Types (Column C) by hand (if possible).

Excel 2010
ABCD
1SalesmanEventTypeLast 2 Event TypesOutput
2a1a
3a2a
4a3a
5a4a
6a5a
7a6a
8b1b
9b2b
10b3b
11b4b
12b5b
13b6b
14b7bab50
15c1c
16c2c
17c3c
18c4c
19c5c
20c6c
21c7c
22c8c
23c9cbc62
24b1b
25b2b
26b3b
27b4b
28b5b
29b6b
30b8bcb47
31c1c
32c2c
33c3c
34c4c
35c5c
36c6c
37c7cbc39

<tbody>
</tbody>
Sheet1
Any help would be appreciated.

Thank you.
 
Hi jtakw,
Thanks again for your help. Would it be difficult to extend the above to 3 rolling events? (i.e. E21 would now be "aab" and E30 would now be "abc", E37 would be "bcb" etc?)

Any assistance would be appreciated.
 
Upvote 0

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
You're welcome, and Welcome back.

Not too difficult, I've updated the formulas for your new request, if you need to include more rolling events in the future (i.e. 4, 5, 6, etc.), you can change the number (highlighted Red) within the formula:

For 2 events: =IF(AND(LEN(G2)>1,D2<>D3),RIGHT(G2,2),"")

For 3 events: =IF(AND(LEN(G2)>1,D2<>D3),RIGHT(G2,3),"")

Etc.


Excel 2010
ABCDEFG
1DateSalesmanEventTypeDateEventIDLast 2 Event TypesLast 3 Event Types
215-Octa1aOct-15-a  a
315-Octa2aOct-15-aa
415-Octa3aOct-15-aa
515-Octa4aOct-15-aa
615-Octa5aOct-15-aa
715-Octa6aOct-15-aa
815-Nova1aNov-15-aaa
915-Nova2aNov-15-aaa
1015-Nova3aNov-15-aaa
1115-Nova4aNov-15-aaa
1215-Nova5aNov-15-aaa
1315-Nova6aNov-15-aaa
1415-Nova7aNov-15-aaaaaaa
1515-Novb1bNov-15-baab
1615-Novb2bNov-15-baab
1715-Novb3bNov-15-baab
1815-Novb4bNov-15-baab
1915-Novb5bNov-15-baab
2015-Novb6bNov-15-baab
2115-Novb7bNov-15-babaabaab
2215-Novc1cNov-15-caabc
2315-Novc2cNov-15-caabc
2415-Novc3cNov-15-caabc
2515-Novc4cNov-15-caabc
2615-Novc5cNov-15-caabc
2715-Novc6cNov-15-caabc
2815-Novc7cNov-15-caabc
2915-Novc8cNov-15-caabc
3015-Novc9cNov-15-cbcabcaabc
3115-Novb1bNov-15-baabcb
3215-Novb2bNov-15-baabcb
3315-Novb3bNov-15-baabcb
3415-Novb4bNov-15-baabcb
3515-Novb5bNov-15-baabcb
3615-Novb6bNov-15-baabcb
3715-Novb8bNov-15-bcbbcbaabcb
Sheet1
Cell Formulas
RangeFormula
E2=IF(AND(LEN(G2)>1,D2<>D3),RIGHT(G2,2),"")
F2=IF(AND(LEN(G2)>1,D2<>D3),RIGHT(G2,3),"")
G2=IF(G1="",C2,IF(D2<>D1,G1&C2,G1))
 
Last edited:
Upvote 0
Ran into a minor snafu in column G. The cells in Column G seems to get wider & wider as more items are appended to it. I have roughly 1,000 events in my dataset so eventually column G reaches its max capacity before the end of the dataset. Any way to trim it to keep that from happening?

Thanks!
 
Upvote 0
How many event types are we going to max out at? Is it 3, or ??
 
Upvote 0
There are 6 event types total (a-f). I am interested in the last 3 events (as noted earlier). The same event can occur all three times (i.e. aaa) or there can be any mix of the event types (i.e. abd, dbf, aaf, etc)
 
Upvote 0
Do you still want to be able to do 2 event types also, or you only want 3?
 
Upvote 0
Only 3 now.


Excel 2010
ABCDEF
1DateSalesmanEventTypeDateEventIDLast 3 Event Types
215-Octa1aOct-15-a a
315-Octa2aOct-15-aa
415-Octa3aOct-15-aa
515-Octa4aOct-15-aa
615-Octa5aOct-15-aa
715-Octa6aOct-15-aa
815-Nova1aNov-15-aaa
915-Nova2aNov-15-aaa
1015-Nova3aNov-15-aaa
1115-Nova4aNov-15-aaa
1215-Nova5aNov-15-aaa
1315-Nova6aNov-15-aaa
1415-Nova7aNov-15-aaaaa
1515-Novb1bNov-15-baab
1615-Novb2bNov-15-baab
1715-Novb3bNov-15-baab
1815-Novb4bNov-15-baab
1915-Novb5bNov-15-baab
2015-Novb6bNov-15-baab
2115-Novb7bNov-15-baabaab
2215-Novc1cNov-15-cabc
2315-Novc2cNov-15-cabc
2415-Novc3cNov-15-cabc
2515-Novc4cNov-15-cabc
2615-Novc5cNov-15-cabc
2715-Novc6cNov-15-cabc
2815-Novc7cNov-15-cabc
2915-Novc8cNov-15-cabc
3015-Novc9cNov-15-cabcabc
3115-Novb1bNov-15-bbcb
3215-Novb2bNov-15-bbcb
3315-Novb3bNov-15-bbcb
3415-Novb4bNov-15-bbcb
3515-Novb5bNov-15-bbcb
3615-Novb6bNov-15-bbcb
3715-Novb8bNov-15-bbcbbcb
Sheet2
Cell Formulas
RangeFormula
E2=IF(AND(LEN(F2)>1,D2<>D3),F2,"")
F2=IF(F1="",C2,IF(D2<>D1,RIGHT(F1,2)&C2,F1))
 
Upvote 0

Forum statistics

Threads
1,216,761
Messages
6,132,568
Members
449,736
Latest member
anthx

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top