Sum maximums matching two other variables

sultanofding

New Member
Joined
Feb 11, 2021
Messages
1
Office Version
  1. 365
Platform
  1. Windows
Hello,
I am trying to create a function to look up a subject number and the sum the 'Days on o2' where it the maximum for matched start dates. ie patient 001-001, sum the max where the start date is 11/6/20 (2), 11/5/20 (2), 11/8 (4), 11/11 (2) - 10 in total, essentially to not double count entries with the same start date.

1613058528908.png
 

Excel Facts

Did you know Excel offers Filter by Selection?
Add the AutoFilter icon to the Quick Access Toolbar. Select a cell containing Apple, click AutoFilter, and you will get all rows with Apple
Welcome to the MrExcel forum!

Here's one way:

Book2
ABCDEF
1SubjectStart DateEnd DateDays on O2Sum of max per date
2001-00111/6/202011/6/2020110
3001-00111/6/202011/6/20201 
4001-00111/6/202011/7/20202 
5001-00111/7/202011/7/20201 
6001-00111/7/202011/8/20202 
7001-00111/8/202011/11/20204 
8001-00111/11/202011/12/20202 
9001-00211/14/20200
10001-00312/10/202012/12/2020313
11001-00312/12/202012/13/20202 
12001-00312/13/202012/14/20202 
13001-00312/14/202012/16/20203 
14001-00312/16/202012/18/20203 
15001-00312/18/2020 
16
Sheet1
Cell Formulas
RangeFormula
F2:F15F2=IF(A2=A1,"",SUMPRODUCT(IFERROR(MAXIFS(D:D,A:A,A2,B:B,B2:B30)/COUNTIFS(A:A,A2,B:B,B2:B30),0)))
Press CTRL+SHIFT+ENTER to enter array formulas.


I suspect there's something better though, I'll look at it some more.
 
Upvote 0

Forum statistics

Threads
1,214,991
Messages
6,122,628
Members
449,095
Latest member
bsb1122

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