Find Most Recent Date with a positive cumulative sum based on criteria

Don Swanson

New Member
Joined
Nov 30, 2022
Messages
3
Office Version
  1. 365
Platform
  1. Windows
Hello,

I am struggling with a formula for work. I have an array with dates assigned to specific individuals. Several of these dates have positive and negative numbers associated with them. Also several of the dates are eligible and some are not. I want a formula that can return the most recent date assigned to a specific person that has a positive sum for all of the numbers associated with that date for that person. In my head I imagine the formula creates a dynamic array with eligible dates per person with the respective sums for each of those dates, then selects the most recent date in column E. I would be able to drag this formula down as my data set grows.

I arranged some data illustrate what I am looking for. Column E demonstrates what the formula would be doing.

John is the best example. He receives 1 point on 9/20, so on 9/21, Column E shows 9/20. However, by the time you get to E10. John has had both a negative and positive eligible point on 9/21, so the date with the most recent sum of positive points is 9/20/22.

Any help would be appreciated.

1670280395575.png
 

Excel Facts

VLOOKUP to Left?
Use =VLOOKUP(A2,CHOOSE({1,2},$Z$1:$Z$99,$Y$1:$Y$99),2,False) to lookup Y values to left of Z values.
If I understood your question correctly, you can get to the result by using a pivot table

On Pivot table
Filter: "Points for that date" and "Is Date Eligible"
Rows: "Name"
Values: "Date"*
Once you put the "Date" under "Value" section, click on the arrow next to Date and select Value Field Settings from the list.
On the new pop up select Max, then click on Number Format button and select a date format. Then click OK.

I hope that's what you wanted.

2022-12-05_15h41_29.png
 
Upvote 0
Thank you so much for the reply. I am familiar with Pivot Table, but I am looking to use a formula in Column E that I can drag down as I add new data that will provide the answer. My thought it is that it would be a dynamic array formula such as Maxif(Date,Sumifs(person,dates,elligible)>0)
 
Upvote 0
The below relies on your data being in ascending date order.
Is your "Is Date Eligible" column manually entered ? There are a number of rows that don't meet the criteria but are still flagged with Yes.
This is supported by the fact that you also use the description "Last eligible date returns negative sum"

My last column ignores that column and just uses your criteria as described by you.

20221207 Last Positive Result Don Swanson.xlsx
ABCDEFGH
1NameDatePoints for that dateIs Date EligibleMost recent, previous, eligible date with positive sum:Orig Most recent, previous, eligible date with positive sum:Most recent, previous, eligible date with positive sum:
2John20/09/20221YesNo Previous eligible dateNo Previous eligible dateNo Previous eligible date
3John21/09/20221Yes20/09/202220/09/202220/09/2022
4Jesse21/09/20222YesNo Previous eligible dateNo Previous eligible dateNo Previous eligible date
5Mark21/09/2022-1YesNo Previous eligible dateNo Previous eligible dateNo Previous eligible date
6Phil21/09/20222noNo Previous eligible dateNo Previous eligible dateNo Previous eligible date
7John21/09/2022-1Yes21/09/202221/09/2022
8Jesse21/09/20222Yes21/09/202221/09/2022
9Mark21/09/20221YesLast eligible date returns negative sumNo Previous eligible date
10Phil21/09/2022-1YesNo Previous eligible dateNo Previous eligible date21/09/2022
11John27/09/20221YesLast eligible date returns negative sum21/09/2022
12Jesse27/09/2022-1Yes21/09/202221/09/2022
13Mark27/09/20222no21/09/202221/09/2022
14Phil27/09/20221noLast eligible date returns negative sumLast eligible date returns negative sum21/09/2022
15John27/09/2022-1Yes27/09/202227/09/2022
16
17Uses Yes/no flagOPs expectations which look inconsistent with criteriaUses base criteria and ignores Yes/no flag which looks wrong
Date
Cell Formulas
RangeFormula
F2:F15F2=LET(prevEligibleRow,XMATCH(1,($A$1:$A1=$A2)*($D$1:$D1="Yes"),0,-1), IFERROR( IF(INDEX($C$1:$C$15,prevEligibleRow)>0, INDEX($B$1:$B$15,prevEligibleRow), "Last eligible date returns negative sum"), "No Previous eligible date"))
H2:H15H2=IFERROR(INDEX($B$1:$B$15,XMATCH(1,($A$1:$A1=$A2)*($C$1:$C1>0),0,-1)), "No Previous eligible date")
 
Upvote 0
Solution

Forum statistics

Threads
1,216,725
Messages
6,132,344
Members
449,719
Latest member
excel4mac

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