# If & COUNTIF Statements for Productivity

#### tspehar21

##### New Member
For my work my productivity is tracked and recorded, however the database software our company uses is garbage and I have an excel spreadsheet that I prefer to use.

So what I track is:
• Encounter #
• If it is a NB (NewBorn), Y for yes, nothing if not
• The LOS (Length Of Stay), #

Depending on the LOS and if it is a NB or not, will depict how many minutes you are allotted for that encounter. For instance a 1-3 day LOS you are given 32.5 min, whereas a 1-3 day LOS NB you are given 22.5 min.

What I want to be able to do is have excel count up how many 1-3 day LOS encounters I have for the week, how many 1-3 day NB LOS encounters, 4-6 day LOS, etc.

I was thinking that this would involve an IF statement to determine if column 2 has a "Y" making it a NB encounter, and then the COUNTIF statement to count how many encounters are 1-3 day LOS (Column 3).

 Encounter# NB LOS 23456 2 34567 Y 1 45678 Y 2 56789 3 67890 Y 2 78901 Y 1 89012 Y 1 90123 4 01234 3

<tbody>
</tbody>

For the above table, there are:
5x 1-3 day LOS NB encounters, (1, 2, 2, 1, 1)
3x 1-3 day LOS encounters (2, 3, 3)
1x 4-6 day LOS encounters (4)

How would you write a formula that would be able to Count each of the above values? I realize I would need a separate formula for each value range, 1-3 day LOS, 1-3 day LOS NB, 4-6 day LOS. Would I have to have a separate formula for 1 day LOS, 2 day LOS, 3 day LOS, then SUM those values? I need to be able to keep the NB encounters separate from the normal ones as they are given a different amount of time, hence my thought for the IF statement. Please let me know what you think.

### Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.

#### Marcelo Branco

##### MrExcel MVP
Welcome to Mr Excel forum

Try something like this

 A​ B​ C​ D​ E​ F​ G​ H​ 1​ Encounter#​ NB​ LOS​ DaysMin​ DaysMax​ NB Y?​ Result​ 2​ 23456​ 2​ 1​ 3​ Y​ 5​ 3​ 34567​ Y​ 1​ 1​ 3​ 3​ 4​ 45678​ Y​ 2​ 4​ 6​ Y​ 0​ 5​ 56789​ 3​ 4​ 6​ 1​ 6​ 67890​ Y​ 2​ 7​ 78901​ Y​ 1​ 8​ 89012​ Y​ 1​ 9​ 90123​ 4​ 10​ 1234​ 3​

Criteria in columns E:G

Formula in H2 copied down
=COUNTIFS(C\$2:C\$10,">="&E2,C\$2:C\$10,"<="&F2,B\$2:B\$10,IF(G2="","",G2))

Hope this helps

M.

Replies
17
Views
219
Replies
3
Views
44
Replies
1
Views
302
Replies
2
Views
210
Replies
4
Views
406

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

1,163,713
Messages
5,833,269
Members
430,200
Latest member

### 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.

### Which adblocker are you using?

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

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