# Average a date difference based on criteria

#### GergelySzakacs

##### New Member
Hi Team,

I am having difficulty with the below problem. I need to average the day differences between two dates, based on other criteria.

So, I would need the average date difference between B and A colums for every A, B, and C categories. So, one day number for A, B and C categories.

I spend so many times already on this, I hope you guys can help me

Thanks,
Gergely

### Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
have you tried the =AVERAGEIF() function?

Yes, I tried, but I got confused after a while. I am confused because of the range. For one line I can understand average if but not for a range. Can you help me how to do that?

it's much easier with a helper column D

Book1
ABCDE
131/01/202207/02/2022A78.5
231/01/202208/02/2022B89.5
331/01/202209/02/2022C99
431/01/202210/02/2022A10
531/01/202211/02/2022B11
Sheet1
Cell Formulas
RangeFormula
E1:E3E1=AVERAGEIF(\$C\$1:\$C\$5,C1,\$D\$1:\$D\$5)
D1:D5D1=B1-A1

I know, but I would avoid any extra column. The source is a spreadsheet that is edited by a lot of people, so I want to keep it as simple as it can be.

ok, try this

Book1
ABCD
131/01/202207/02/2022A8.5
231/01/202208/02/2022B9.5
331/01/202209/02/2022C9
431/01/202210/02/2022A
531/01/202211/02/2022B
Sheet1
Cell Formulas
RangeFormula
D1:D3D1=SUMPRODUCT(--((\$C\$1:\$C\$5=C1)*(\$B\$1:\$B\$5-\$A\$1:\$A\$5)))/COUNTIF(\$C\$1:\$C\$5,C1)

Replies
0
Views
93
Replies
5
Views
374
Replies
7
Views
252
Replies
3
Views
88
Replies
3
Views
193

1,196,516
Messages
6,015,679
Members
441,915
Latest member
sm Hussaini

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