Count only if 2 conditions are met

DJ Winzlow

New Member
Joined
Jun 8, 2018
Messages
3
Hi everyone.

This is my first time posting. I am trying to write a formula to only count if 2 conditions are met.
In Sheet1 I have a table which has 'task names' in column A and in column B 'elapsed time' (how long the task has been opened for in hours).

In Sheet2 I have a table which I am trying to write the formulas to which has 'Task name' in column A and then columns with number of days outstanding (column B '0 days', column C '1 Day' etc..- basically an aging profile of the tasks in days (not hours). I have also added a reference table in sheet2 to as the rule to convert hours to days i.e. 0 - <=8 equals 1 day, >8.01 - <=16 equals 2 days.

Here is what I am trying to achieve.

Condition 1 - The task name in Sheet2 cell A2 must match the task name in Sheet1 column A (only count if the task name matches) THEN
Condition 2 - Now in Sheet1 column B (Elapsed time) I need it to count only the times within the criteria so for day 1 I need it to only return a count of how many are within the required range.

I can write the formulas for each individually but cannot combine the two to achieve the final outcome.

Name Match: =COUNTIFS('Aging Profile Data'!A4:A1661,'Aging Profile Dashboard'!A2)

Count how may in range - =COUNTIF('Aging Profile Data'!A2:A91,'Aging Profile Dashboard'!Q13(Reference Table)-COUNTIF('Aging Profile Data'!A4:A91,'Aging Profile Dashboard'!P13(Reference Table))

Any help would be much appreciated!!???

Sheet1:
TaskElapsed Time
Complex383.12
Complex187.00
Complex58.00
Complex51.00
Complex45.02
Complex41.27
Complex34.00
Complex16.93
Corporate697.00
Corporate588.17

<tbody>
</tbody>

Sheet2:

ServiceDay 0Day 1Day 2Day 3
Complex
Corporate
Simple
Balance

<tbody>
</tbody>

Reference table (to convert to days)

Day><=
008
18.0116
216.0124
324.0132
432.0140
540.0148
648.0156
756.0164
864.0172
972.0180
1080.0188
1188.0196
1296.01104
13104.001112
14112.01120
15120.1128
16+>128.01

<tbody>
</tbody>
 

Excel Facts

Format cells as currency
Select range and press Ctrl+Shift+4 to format cells as currency. (Shift 4 is the $ sign).
A
B
C
D
E
F
G
H
I
J
K
L
1
TaskElapsed TimeServiceDay 0Day 1Day 2Day 3Day 4Day 5Day 6Day 7
2
Complex
383.12​
Complex
0​
0​
0​
1​
0​
1​
2​
1​
3
Complex
187​
Corporate
0​
0​
0​
0​
0​
0​
0​
0​
4
Complex
58​
Simple
0​
0​
0​
0​
0​
0​
0​
0​
5
Complex
51​
Balance
0​
0​
0​
0​
0​
0​
0​
0​
6
Complex
45.02​
7
Complex
41.27​
Day><=
8
Complex
34​
0​
0​
8​
9
Complex
16.93​
1​
8.01​
16​
10
Corporate
697​
2​
16.01​
24​
11
Corporate
588.17​
3​
24.01​
32​
12
4​
32.01​
40​
13
5​
40.01​
48​
14
6​
48.01​
56​
15
7​
56.01​
64​
16
8​
64.01​
72​
17
9​
72.01​
80​
18
10​
80.01​
88​
19
11​
88.01​
96​
20
12​
96.01​
104​
21
13​
104.001​
112​
22
14​
112.01​
120​
23
15​
120.1​
128​
24
16+
128.01​
Sheet: Sheet2

This seems to work. Array formula in cell E2:

=INDEX(FREQUENCY(IF($D2=$A$2:$A$11,$B$2:$B$11,""),$E$8:$E$23),COLUMNS($A$1:A1))

How to enter an array formula.
1. Paste formula to cell E2.
2. Press and hold CTRL + SHIFT
3. Press Enter
 
Upvote 0
Hi,

try this:


Book1
ABCDER
1ServiceDay 0Day 1Day 2Day 3Day 16 +
2Complex00102
3Corporate00002
4Simple00000
Sheet2
Cell Formulas
RangeFormula
B2=COUNTIFS(Sheet1!$A$2:$A$11,Sheet2!$A2,Sheet1!$B$2:$B$11,"<="&8*(1+VALUE(RIGHT(Sheet2!B$1,2))),Sheet1!$B$2:$B$11,">"&8*(VALUE(RIGHT(Sheet2!B$1,2))))
R2=COUNTIFS(Sheet1!$A$2:$A$11,Sheet2!$A2,Sheet1!$B$2:$B$11,">="&8*16)

@oscar, Your solution will work correctly if you change the array used for the determination of number of days.
=INDEX(FREQUENCY(IF($D2=$A$2:$A$11,$B$2:$B$11;""),$F$8:$F$23),COLUMNS($A$1:A1))
 
Last edited:
Upvote 0

Forum statistics

Threads
1,215,219
Messages
6,123,681
Members
449,116
Latest member
HypnoFant

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