count last n times TRUE in column, skip is not TRUE or FALSE

frederik00

New Member
Joined
Jul 25, 2024
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hello everyone, nice to meet all of you!

I tried figuring this out but I couldn't find anything online.

Last 5 times TRUE, skip anything that's not TRUE or FALSE. See my example :)

I like to change the number a lot so if it's possible for it to be dynamic so I can change the 5 to something else, it would be awesome!
 

Attachments

  • ZRBUZSBzHN5.png
    ZRBUZSBzHN5.png
    7.2 KB · Views: 19

Excel Facts

How to fill five years of quarters?
Type 1Q-2023 in a cell. Grab the fill handle and drag down or right. After 4Q-2023, Excel will jump to 1Q-2024. Dash can be any character.
Here is an attempt:

Excel Formula:
=LET(
array,--(TOCOL(A1:B9)),
nth,C2,
count,SUM(array),
seq,WRAPROWS(SCAN(count+1,array,LAMBDA(a,b,IF(b=0,a,a-1)))*array,2),
a,IFERROR(ROWS(FILTER(CHOOSECOLS(seq,1),(CHOOSECOLS(seq,1)>0)*(CHOOSECOLS(seq,1)<=nth))),0),
b,IFERROR(ROWS(FILTER(CHOOSECOLS(seq,2),(CHOOSECOLS(seq,2)>0)*(CHOOSECOLS(seq,2)<=nth))),0),
HSTACK(a,b))

where "C2" represents the cell where there is the value of last N.
 
Upvote 1
How about:

Book1
ABC
1TRUEFALSE
2TRUE5
3TRUEFALSE
4FALSETRUE
5FALSETRUE
6FALSE
7TRUETRUE
8FALSEFALSE
9TRUE
10
1123
Sheet1
Cell Formulas
RangeFormula
A11:B11A11=SUM(--LET(a,FILTER(A1:A9,A1:A9<>""),DROP(a,COUNTA(a)-$C$2)))
 
Upvote 1
Solution

Forum statistics

Threads
1,223,227
Messages
6,170,848
Members
452,361
Latest member
d3ad3y3

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