Find Last Date Where Amount > 0

masouder

Board Regular
Joined
Jul 5, 2013
Messages
111
Office Version
  1. 2013
Platform
  1. Windows
I am trying to calculate the last date for a designated account from a table where the net Amount for that account on that date is greater than 0 (in other words, where there was no return). I'm pretty sure this can be solved with an array formula (or SUMPRODUCT?), but I cannot figure out how to do it. Please see below.

In the below example I am trying to identify the last date for Account 1. Because the net amount for 08/03/2022 is 0 the formula should return 08/02/2022. I can write the array formula to calculate the last date (see cell G7 with formula displayed in H7), but I cannot figure out how to add a component to the formula that excludes dates where the net amount is 0. Can anyone help with a solution?

Book2
ABCDEFGHIJ
1
2
3
4DateAccountAmount
58/1/2022110
68/2/2022110Account1
78/3/2022110Last Date8/3/2022=MAX(IF((C5:C12=G6),B5:B12))
88/3/20221-10
98/1/202225
108/2/202225
118/2/20222-5
128/4/202225
13
14
Sheet1
Cell Formulas
RangeFormula
G7G7=MAX(IF((C5:C12=G6),B5:B12))
Press CTRL+SHIFT+ENTER to enter array formulas.


Thank you!
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Is your profile showing the correct version of Excel?

I haven't tried anything yet, but I suspect that this would be much more difficult to achieve with Excel 2013 than with Office 365.
 
Upvote 0
Is your profile showing the correct version of Excel?

I haven't tried anything yet, but I suspect that this would be much more difficult to achieve with Excel 2013 than with Office 365.
Yes, Excel 2013.
 
Upvote 0
I was just trying a couple of things whilst waiting for you to reply and think I may have cracked it a little easier than I first thought possible. I've only done a quick test with your sample data but can see no reason for this to fail with different data.
This will need to be array confirmed in Excel 2013.
Excel Formula:
=MAX(IF(SUMIFS(D5:D12,C5:C12,C5:C12,B5:B12,B5:B12)>0,IF(C5:C12=G6,B5:B12)))
 
Upvote 0
Solution
Thank you, that appears to be it. I was close, but couldn't quite get it.

Curious, you mentioned an easier solution in 365. Can you share what solution is?
 
Upvote 0
Curious, you mentioned an easier solution in 365.
When I said that, I was expecting the formula for 2013 to be much more complicated than it turned out to be. I think that the current formula will be as good as it gets.
 
Upvote 0
When I said that, I was expecting the formula for 2013 to be much more complicated than it turned out to be. I think that the current formula will be as good as it gets.
Thank again.

One last question. I attempted to rewrite the formulas using the AND function to reduce the two IF functions to one, but it does not work (returns 0). I did remember to enter it as an array formula. Any idea why it does not work?

Excel Formula:
=MAX(IF(AND(C5:C12=G6,SUMIFS(D5:D12,C5:C12,C5:C12,B5:B12,B5:B12)>0),B5:B12))
 
Upvote 0
Using 2 IF's enables us to separate the TRUE and FALSE results from the array (only the TRUE ones are useful). As soon as you thrown AND into it the hierarchy changes and a single FALSE result takes priority over any TRUE results, wiping out the useful data that the 2 IF's can separate.
 
Upvote 0

Forum statistics

Threads
1,216,095
Messages
6,128,794
Members
449,468
Latest member
AGreen17

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