Count Each Row In Dynamic Range Once If Any Cell > 0

smokeyclimber

New Member
Joined
Aug 5, 2014
Messages
4
I have a data set with unique IDs in column B and dates in row 2. I am trying to make a formula that looks at a date I've selected, finds that column in the data sheet, looks at at a range that includes the found column and the 11 before it (i.e., a whole year), then counts the number of rows that have a value > 0 in that range.

I have a formula right now that returns the raw count, but I'm struggling with how to only count a row once.

The formula I started with is below.

=COUNTIFS(INDIRECT(CONCATENATE("Data!",LEFT(INDEX(Data!$A$1:$DK$2,1,MATCH(B$1,Data!$A$2:$DK$2,0)),3),":",LEFT(OFFSET(INDEX(Data!$A$1:$DK$2,1,MATCH(B$1,Data!$A$2:$DK$2,0)),0,-12),3))),">"&0)-2

If there was a ROWSIF function, I'd just use that.

Does anyone know how to count the rows only once without making a helper sheet?
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
Try this and let me know if it does what you want. I've placed the data and your input/output on the same sheet, so you'll need to split those and add sheet references. Input date in AA1 and count of rows containing some value >0 in AB1...and that meant I needed to move the unique ID from B to some other column (AA). Those edits should be straightforward to fit your table structure. What should happen if 11 columns to the left of the matching column are not available...or is that not possible when you select an input date?
MrExcel_20220610.xlsx
ABCDEFGHIJKLMNOPQRSTUVWXYZAAAB
15/1/20226
2Jan-21Feb-21Mar-21Apr-21May-21Jun-21Jul-21Aug-21Sep-21Oct-21Nov-21Dec-21Jan-22Feb-22Mar-22Apr-22May-22Jun-22Jul-22Aug-22Sep-22Oct-22Nov-22Dec-22Jan-23Feb-23
311
423
515
637
79
810
918
1026
11434
12562
Sheet8
Cell Formulas
RangeFormula
AB1AB1=SUMPRODUCT(--(MMULT(--(OFFSET(INDEX($A$3:$Z$12,,MATCH($AA$1,$A$2:$Z$2,0)),,-11,COUNTA($AA$3:$AA$12),12)>0),{1;1;1;1;1;1;1;1;1;1;1;1})>0))
B2:Z2B2=EDATE(A2,1)
 
Last edited:
Upvote 0
I suggest that you update your Account details (or 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’)
 
Upvote 0

Forum statistics

Threads
1,215,059
Messages
6,122,918
Members
449,094
Latest member
teemeren

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