Count "last value" occurances

DutchKevin

Board Regular
Joined
Apr 13, 2011
Messages
133
Office Version
  1. 365
Platform
  1. Windows
Hello friends of excel

For planning reasons we maintain an ever changing matrix of values.
I would like to use a formula to count how many times the last value in a row has appeared at the end of that row.

For example.
My data-row looks something like this:
A,A,B,B,B,C,D,D,B,B,B,B,A,A,C,B,B
I currently count the non blank cells in the row and then use Index to pick then the last value (=B) into a helper column.
How would you get a formula (?) to know that last value (=B) happened two times before the end of the data in the row? :confused:
The nr of values increase every week by one.

Thanks for helping!
Kevin
 

Excel Facts

Which Excel functions can ignore hidden rows?
The SUBTOTAL and AGGREGATE functions ignore hidden rows. AGGREGATE can also exclude error cells and more.
=RIGHT(A12)=MID((A12),(LEN(A12)-2),1), if the data is in cell a12.
This will tell you if the last two letters are the same in a12 no matter how long the data is, if I understand what you are looking for.
 
Upvote 0
Hi Haldoug,
Thanks for replying.
I tried your welcome suggestion but, unforfunately, my data is in seperate cells, so i think that your suggestion does not apply then?

Each next week, in this example, the row expands with another cell, with another letter.

I'm looking in the direction of;
- in a row, find last cells position [solved]
- then (optional) link that last cell's value into a helper column [also solved]
- count cells backwards from last cells position until the cell-value is different. [problem]

Do you have any other ideas?

Thanks, Kevin
 
Upvote 0
Hello friends of excel

For planning reasons we maintain an ever changing matrix of values.
I would like to use a formula to count how many times the last value in a row has appeared at the end of that row.

For example.
My data-row looks something like this:
A,A,B,B,B,C,D,D,B,B,B,B,A,A,C,B,B
I currently count the non blank cells in the row and then use Index to pick then the last value (=B) into a helper column.
How would you get a formula (?) to know that last value (=B) happened two times before the end of the data in the row? :confused:
The nr of values increase every week by one.

Thanks for helping!
Kevin
Given the following 3 rows...

A,A,B,B,B,C,D,D,B,B,B,B,A,A,C,B,B
A,D,B,@,B
B,B,B,V

where @ stands for an empty/blank cell, what is the desired outcome?
 
Upvote 0
Hello friends of excel​


For planning reasons we maintain an ever changing matrix of values.
I would like to use a formula to count how many times the last value in a row has appeared at the end of that row.​

For example.
My data-row looks something like this:
A,A,B,B,B,C,D,D,B,B,B,B,A,A,C,B,B
I currently count the non blank cells in the row and then use Index to pick then the last value (=B) into a helper column.
How would you get a formula (?) to know that last value (=B) happened two times before the end of the data in the row? :confused:
The nr of values increase every week by one.​

Thanks for helping!
Kevin​
Try this...

Book1
ABCDEFGHIJKLMNOPQ
1AABBBCDDBBBBAACBB
2_________________
3B2_______________
Sheet1

Enter this formula in A3. This will return the right-most TEXT entry from the range A1:Q1.

=LOOKUP("zzzzz",A1:Q1)

Enter this array formula** in B3. This will return the current "streak".

=LOOKUP(1E100,FREQUENCY(IF(A1:Q1=A3,COLUMN(A1:Q1)),IF(A1:Q1<>A3,COLUMN(A1:Q1))))

** array formulas need to be entered using the key
combination of CTRL,SHIFT,ENTER (not just ENTER).
Hold down both the CTRL key and the SHIFT key
then hit ENTER.
 
Upvote 0
Re: Count "last value" occurances [solved]

Hello T.Valko

This is exactly what I needed.
I'm a bit puzzled how it actually works, especially since its in an array formula, but for sure this solves the question.

Thanks very much.

Kevin
 
Upvote 0
Re: Count "last value" occurances [solved]

For everybody else looking for something like this i paste my final formula below.
It works from one cell (A1 for instance) and evaluates the range (C1:XFD1)

- data starts in Cell C1 and then fills the row as long as you want.

Code:
=LOOKUP(1E+100;FREQUENCY(IF(C1:(OFFSET(B1;0;COUNTA(C1:XFD1)))=OFFSET(B1;0;COUNTA(C1:XFD1));COLUMN(C1:(OFFSET(B1;0;COUNTA(C1:XFD1)))));IF(C1:(OFFSET(B1;0;COUNTA(C1:XFD1)))<>OFFSET(B1;0;COUNTA(C1:XFD1));COLUMN(C1:(OFFSET(B1;0;COUNTA(C1:XFD1)))))))

This works for text-values as well as number-values in the cells

Note that the used offset function uses B1 as reference cell
Note also that you need to enter this as an array formula:
Array formulas need to be entered using the key combination of CTRL,SHIFT,ENTER (not just ENTER). Hold down both the CTRL key and the SHIFT key then hit ENTER.
 
Upvote 0
Re: Count "last value" occurances [solved]

Hello T.Valko

This is exactly what I needed.
I'm a bit puzzled how it actually works, especially since its in an array formula, but for sure this solves the question.

Thanks very much.

Kevin
You're welcome. Thanks for the feedback! :cool:
 
Upvote 0

Forum statistics

Threads
1,224,521
Messages
6,179,275
Members
452,902
Latest member
Knuddeluff

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