Extracting most recent values greater than 0

Smurphster16

New Member
Joined
Feb 28, 2019
Messages
25
Hi guys,

I have a worksheet that has IDs in column A , values in column B and dates in column C.

In some cases the the value for a given ID on a given date is 0.

Therefore on a separate sheet I want a unique list of IDS and the value for each ID with the latest date that is greater than 0.

Initially I had this formula - but it only works if all the values that are greater than 0 for a particular ID are for consecutive dates - is there a way to get this so that it doesn't matter if the values greater than 0 are not for consecutive dates?
(unique ID list starts in separate sheet at A2 and sheet below is the AM upload)

=IFNA(INDEX('AM Upload'!C:C,MATCH(A2,'AM Upload'!A:A,0)+COUNTIFS('AM Upload'!A:A,A2,'AUM Upload'!C:C,">"&0)-1),"")

b 369,154,383
30/06/2019​
b 378,582,711
31/07/2019​
b 360,129,923
31/08/2019​
b 363,685,213
30/09/2019​
b 364,375,372
31/10/2019​
b 379,777,014
30/11/2019​
b 380,403,091
31/12/2019​
b -
31/01/2020​
d 334,440,169
30/06/2019​
d 329,340,127
31/07/2019​
d 333,324,290
31/08/2019​
d 320,730,918
30/09/2019​
d 322,417
31/10/2019​
d 324,926,841
30/11/2019​
d 294,756,141
31/12/2019​
d 290,706
31/01/2020​
c 22,000,000
30/06/2019​
c -
31/07/2019​
c -
31/08/2019​
c 39,186,153,000
30/09/2019​
c -
31/10/2019​
c -
30/11/2019​
c 37,289,080,000
31/12/2019​
c -
31/01/2020​
g 1,796,151,592
30/06/2019​
g 1,800,487
31/07/2019​
g 1,024,939
31/08/2019​
g 1,872,347
30/09/2019​
Thanks,
 

Excel Facts

Is there a shortcut key for strikethrough?
Ctrl+S is used for Save. Ctrl+5 is used for Strikethrough. Why Ctrl+5? When you use hashmarks to count |||| is 4, strike through to mean 5.
try this

Book1
ABCDEF
1b369,154,38330/06/2019b380,403,091
2b378,582,71131/07/2019c37,289,080,000
3b360,129,92331/08/2019d290,706
4b363,685,21330/09/2019g1,872,347
5b364,375,37231/10/2019
6b379,777,01430/11/2019
7b380,403,09131/12/2019
8b-31/01/2020
9d334,440,16930/06/2019
10d329,340,12731/07/2019
11d333,324,29031/08/2019
12d320,730,91830/09/2019
13d322,41731/10/2019
14d324,926,84130/11/2019
15d294,756,14131/12/2019
16d290,70631/01/2020
17c22,000,00030/06/2019
18c-31/07/2019
19c-31/08/2019
20c39,186,153,00030/09/2019
21c-31/10/2019
22c-30/11/2019
23c37,289,080,00031/12/2019
24c-31/01/2020
25g1,796,151,59230/06/2019
26g1,800,48731/07/2019
27g1,024,93931/08/2019
28g1,872,34730/09/2019
Sheet1
Cell Formulas
RangeFormula
F1:F4F1=INDEX($B$1:$B$28,MATCH(E1&MAXIFS($C$1:$C$28,$A$1:$A$28,E1,$B$1:$B$28,">"&0),$A$1:$A$28&$C$1:$C$28,0))
Press CTRL+SHIFT+ENTER to enter array formulas surrounded with curly braces.
 
Upvote 0
Hi ,

thanks very much for the solution.

Unfortunately i am running excel 2016 - so i don't think the max-ifs function is available to me?

Is there an alternate solution?

Thanks very much
 
Upvote 0
another way with Power Query (Get&Tramsform)
IDMaxDateValue
b31/12/2019380403091
c31/12/201937289080000
d31/01/2020290706
g30/09/20191872347

Code:
// Table1
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Type = Table.TransformColumnTypes(Table.SelectRows(Source, each [Value] <> "-"),{{"Value", Int64.Type}, {"Date", type date}}),
    Group = Table.Group(Type, {"ID"}, {{"MaxDate", each List.Max([Date]), type date}, {"Count", each _, type table}}),
    Value = Table.AddColumn(Table.Sort(Group,{{"ID", Order.Ascending}}), "Value", each List.Last([Count][Value]))
in
    Value

btw. update your profile (Account details) about Excel version. Less troubles and wasted posts.
 
Upvote 0
Hi ,

thanks very much for the solution.

Unfortunately i am running excel 2016 - so i don't think the max-ifs function is available to me?

Is there an alternate solution?

Thanks very much

depends on the format of your cells, one of the 2 array formula should work

=INDEX($B$1:$B$28,MATCH(E1&MAX(IF($B$1:$B$28>0,IF($A$1:$A$28=E1,$C$1:$C$28))),$A$1:$A$28&$C$1:$C$28,0))

or

=INDEX($B$1:$B$28,MATCH(E1&MAX(IF(ISNUMBER($B$1:$B$28),IF($A$1:$A$28=E1,$C$1:$C$28))),$A$1:$A$28&$C$1:$C$28,0))
 
Upvote 0

Forum statistics

Threads
1,214,516
Messages
6,119,980
Members
448,934
Latest member
audette89

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