formula to give sample number of a certain sample type and on a certain day

New Contributor

Good afternoon,


I need some help with a formula I want to use.

I am trying to put together a formula that gives me a number if some conditions are met. The example excel is as follows:

ProductsampleDate TimeNumber of samples per day



I want a formula in the Number of samples per day column. It should check if the productsample is Wheat or Rye. Then if it is the first sample of that day or if it is the 2nd or third, etc. So the output I want to be in column D in this case would be: 

ProductsampleDate TimeNumber of samples per day


Can someone tell me if this is possible? Preferably without macro's


Many thanks in advance!

2 Replies



This formula returns the intended result in my sheet.

number of samples per day.JPG


 It is possible to achieve the desired result without using macros.

You can use the COUNTIFS function in Excel to count the number of samples for each product on a given day.

Here’s an example formula that you can use in cell D2 and then drag down to fill the rest of the column:


This formula counts the number of rows in column A (Productsample) that match the current row’s product and have a date in column B (Date) that matches the current row’s date.

The result is the number of samples for that product on that day up to and including the current row.


See the file!


I hope this helps!