COUNTIF each occurrence and subtract 2 from each occurence

lorileirn

New Member
Joined
Feb 10, 2016
Messages
5
Trying to calculate the number of "T's" in a table row and I do not want to count the first or the last occurrence, so in essence I want to subtract 2 from whatever my total is. I have that working, maybe not efficiently, but it is working.

Here is what I have:

=(COUNTIF(tblJanuary[@[1]:[31]],"T")-2) - this is calculated in hidden columns.

=IF(AQ5<=0,0,AQ5) - this is in the visible columns

There is a possibility that there could be a break in the occurrences. In other words, person leaves and is gone 5 days and comes back for 2 days and then is gone again for 4 days. I would need to subtract 2 from each of the instances and only count the number of days less the first and last day of each occurrence. How do I count/calculate each occurrence and subtract the first and last day of each?


I hope that makes sense.
Thank you so much,
Lori
 

Excel Facts

Excel Can Read to You
Customize Quick Access Toolbar. From All Commands, add Speak Cells or Speak Cells on Enter to QAT. Select cells. Press Speak Cells.
Hi Lori,

What if person gone for 2 days only ?
Can you share a sample data with your expected output ?



Regards,
DILIPandey
 
Upvote 0
I tried to post a picture with this and had a difficult time. However, they wouldn't take only 2 days, they would take at least 3 and most of the time 5.
When I get back to my desk I will try again to post a picture.
Thank you.
 
Upvote 0
Leave.JPG

Hoping this dropbox link works with the picture. Thank you.
 
Upvote 0
Okay.. I saw the picture and seems to be simple one... just countif for "T" and subtract 2 from the result and I guess you already achieved this.

I would need to subtract 2 from each of the instances and only count the number of days less the first and last day of each occurrence.

If you have instances of t in range A7:O7, use below formula p7:-

=COUNTIF($A$7:$O$7,"t")-SUMPRODUCT((FREQUENCY(IF($A$7:$O$7="T",COLUMN($A$7:$O$7),""),IF($A$7:$O$7<>"T",COLUMN($A$7:$O$7),""))>0)*1)*2

Confirm formula with key combination ctrl shift enter.


Regards,
DILIPandey
 
Upvote 0

Forum statistics

Threads
1,223,230
Messages
6,170,883
Members
452,364
Latest member
springate

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