Count If

mouzzampk2014

New Member
Joined
Sep 6, 2016
Messages
24
Hi all, need little bit help with the calculation. I have spreadsheet which shows if camera is working or not.

I am trying to count number of days camera wasn't working. In Status column I have Working, Not Working and Out of Schedule.

I cannot figure it out how to count if camera wasn't working before out of schedule and/or after out of schedule. Basically I am trying to see if camera was not working before out of schedule that means camera was also not working on out of schedule days.

CameraDateStatus
MT2889
01/01/2023​
Working
MT2889
02/01/2023​
Working
MT2889
03/01/2023​
Not Working
MT2889
04/01/2023​
Not Working
MT2889
05/01/2023​
Out of Schedule
MT2889
06/01/2023​
Out of Schedule
MT2889
07/01/2023​
Not Working
MT2889
08/01/2023​
Working
MT2889
09/01/2023​
Working
MT2889
10/01/2023​
Not Working
MT2889
11/01/2023​
Not Working
MT2889
12/01/2023​
Out of Schedule
MT2889
13/01/2023​
Out of Schedule
MT2889
14/01/2023​
Working
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
With your table and CAMERA in cell A1,
=IF(OR(C2="Working",AND(C2="Out of Schedule",D1=0)),0,1)
This gives a 0 if it is adjacent to a Working or if on an OUT day, it was working the day before
Otherwise it is a 1
Then you can do a simple SUMIF and even incorporate a date range if you wish

There are likely more sophisticated ways but this seems to work
 
Upvote 1
Solution
With your table and CAMERA in cell A1,
=IF(OR(C2="Working",AND(C2="Out of Schedule",D1=0)),0,1)
This gives a 0 if it is adjacent to a Working or if on an OUT day, it was working the day before
Otherwise it is a 1
Then you can do a simple SUMIF and even incorporate a date range if you wish

There are likely more sophisticated ways but this seems to work
This is amazing and worked :) thank you so much.

Can I just ask what is this doing
Rich (BB code):
D1=0
 
Upvote 0
This is amazing and worked :) thank you so much.

Can I just ask what is this doing
Rich (BB code):
D1=0
The D1 = 0 is checking if the previous value was a 0 (working) so working on one day and Off the next means working on the Off day
If it was not a 0... a 1, that means that it was NOT working on the day preceding the OFF day, so not working on the OFF day
 
Upvote 0
The D1 = 0 is checking if the previous value was a 0 (working) so working on one day and Off the next means working on the Off day
If it was not a 0... a 1, that means that it was NOT working on the day preceding the OFF day, so not working on the OFF day
Thank you for your time. Much appreciated.
 
Upvote 0

Forum statistics

Threads
1,215,339
Messages
6,124,373
Members
449,155
Latest member
ravioli44

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