COUNTIF Based on Two Criteria

dcunningham

Board Regular
Joined
Jul 14, 2015
Messages
58
Hi Everyone,

First, a bit of background. I have access to a database that provides me with engine status codes for a vehicle with a time stamp. This engine status code is in decimal, but needs to be converted to binary to be read because each engine status (No Engine Speed, Engine Derate, and so on) are assigned to one of the sixteen bits. I have figured out how to convert these decimal values to binary, and then how to split up the binary string into individual cells. My data now looks like this:

359785dfe236b81d5545105dfc59a958.png

That's just a sample, the values go on to row 8656. So, Column E has the time stamps, Column F has the engine status (in decimal, these change even if they do only look to have a value of 1 or 65 in the sample I provided), Column G is Column F converted into 16-bit binary, and Columns H to W are each individual bit of the string in Column G. The black box contains values that I needed to hide, they're used as part of the query to the aforementioned database.

Now, what I'd like to do is count the number of times both of the two following conditions are met for each column in Columns H through W: (1) the value in the column is 1 consecutively 5 times or more, and (2) the time stamps (in column E) for each of those consecutive events are within two minutes of each other. In this instance, an event that meets those conditions is considered an event where one of those engine statuses was actually active and not just a brief blip. I need to know this for each bit column. Ideally these functions would go in H3:W3, above the bit columns. For a point of reference, Number of Values is located in Cell E6.

The end result based on the above data would look something like:

df0c5e7cf06c154f793b710b45467167.png


Where the highlighted values would be the number of instances of what I've defined as an 'event'.

Any help you can provide would be greatly appreciated.
 

Excel Facts

Back into an answer in Excel
Use Data, What-If Analysis, Goal Seek to find the correct input cell value to reach a desired result

Forum statistics

Threads
1,214,391
Messages
6,119,249
Members
448,879
Latest member
oksanana

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