Multi-line sequence counting...

wabbit_47

New Member
Joined
Feb 9, 2012
Messages
12
Howdy guru's! :geek:

Bit of a tricky one, but really hoping someone can help me crunch some traffic signal data.

In an exported .csv spreadsheet, I get a separate row for each time a phase is activated, with either phase A, B or C in the Phase column.

What I need to do is establish how often each sequence occurs within the column before returning to <A>. For example...

<A>
B
<A>
B
<A>
B
C
<A>
B
C
<A>
B
<A>
C

How often did ABC occur; how often did AB occur; how often did AC occur?

Doth any formula exist that could count the sequence that occurs before the sequence returns to an <A> value??

Thanks!
Wabbit_47
 

Excel Facts

Copy PDF to Excel
Select data in PDF. Paste to Microsoft Word. Copy from Word and paste to Excel.
ok assuming your data starts in A1, create a helper column in B1 and try the following which will produce 123 for a full house, where A=1, B=2, C=3

=IF(A1="<A>",IF(AND(A2="B",A3="C"),"123",IF(A2="B","12",IF(A2="C","13","1"))),"")

drag the formula down for all of you data

You can then use COUNTIF on your helper column to look for 123, 12, 13, 1

sequence.xlsx
AB
1<A>12
2B 
3<A>12
4B 
5<A>123
6B 
7C 
8<A>123
9B 
10C 
11<A>12
12B 
13<A>13
14C 
15<A>1
16<A>123
17B
18C
Sheet1
Cell Formulas
RangeFormula
B1:B16B1=IF(A1="<A>",IF(AND(A2="B",A3="C"),"123",IF(A2="B","12",IF(A2="C","13","1"))),"")
 
Last edited:
Upvote 0
ok assuming your data starts in A1, create a helper column in B1 and try the following which will produce 123 for a full house, where A=1, B=2, C=3

=IF(A1="<A>",IF(AND(A2="B",A3="C"),"123",IF(A2="B","12",IF(A2="C","13","1"))),"")

drag the formula down for all of you data

You can then use COUNTIF on your helper column to look for 123, 12, 13, 1




Thank you sooooo much for this! Absolutely perfect! Great solution :)
 
Upvote 0
Thanks for the feedback
Are you happy with COUNTIF is it giving correct results
 
Upvote 0
Thanks for the feedback
Are you happy with COUNTIF is it giving correct results
It sure is...the COUNTIF function then means I can crunch it further to calculate percentages of how often each possible cycle sequence happens and apply the percentage factor to extrapolate the sequence trends and adjust timings

Very cool in a non-cool kinda way :ROFLMAO::geek:
 
Upvote 0
Could you just use the letters directly instead of going via a numerical code?

BTW, I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

Also investigate XL2BB for providing sample data & expected results to make it easier for helpers to understand just what you have & where it is and also what you want & where it is to be.

20 07 08.xlsm
AB
1<A>AB
2B 
3<A>AB
4B 
5<A>ABC
6B 
7C 
8<A>ABC
9B 
10C 
11<A>AB
12B 
13<A>AC
14C 
15<A>A
16<A>ABC
17B 
18C 
Sequence
Cell Formulas
RangeFormula
B1:B18B1=IF(A1="<A>","A"&IF(A2="<A>","",SUBSTITUTE(A2&A3,"<A>","")),"")
 
Upvote 0
A
Could you just use the letters directly instead of going via a numerical code?

BTW, I suggest that you update your Account details (click your user name at the top right of the forum) so helpers always know what Excel version(s) & platform(s) you are using as the best solution often varies by version. (Don’t forget to scroll down & ‘Save’)

Also investigate XL2BB for providing sample data & expected results to make it easier for helpers to understand just what you have & where it is and also what you want & where it is to be.

20 07 08.xlsm
AB
1<A>AB
2B 
3<A>AB
4B 
5<A>ABC
6B 
7C 
8<A>ABC
9B 
10C 
11<A>AB
12B 
13<A>AC
14C 
15<A>A
16<A>ABC
17B 
18C 
Sequence
Cell Formulas
RangeFormula
B1:B18B1=IF(A1="<A>","A"&IF(A2="<A>","",SUBSTITUTE(A2&A3,"<A>","")),"")
I shall do that, thanks for the tip :)
 
Upvote 0

Forum statistics

Threads
1,214,923
Messages
6,122,289
Members
449,077
Latest member
Rkmenon

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