SOLVED

How to identify the most recent transaction

Copper Contributor

Hello,

 

I have a transaction table where serial numbers may be listed more than once if they were sold, returned and sold again.  I need a way to create a column to identify the most recent transaction for each serial number so I can filter by the identifier and exclude transactions that are not the most recent in my data set.  Below is a sample: 

BRANDInvoice DateSales #Model #ITEM_DESCQtySERIAL_NBR
WIDGIT6/20/2019R123Model 1Unit XYZ-1Serial 1
WIDGIT5/20/2019S123Model 1Unit XYZ1Serial 1
WIDGIT11/29/2017S124Model 1Unit XYZ1Serial 1
WIDGIT11/29/2017S125Model 3Unit XYZ1Serial 3
WIDGIT1/15/2020S130Model 4Unit XYZ1Serial 4
WIDGIT12/1/2019R126Model 4Unit XYZ-1Serial 4
WIDGIT9/20/2019S126Model 4Unit XYZ1Serial 4
WIDGIT9/20/2019S127Model 5Unit XYZ1Serial 5
WIDGIT10/15/2019S128Model 6Unit XYZ1Serial 6

 

Thank you in advance.

5 Replies
best response confirmed by szub_2 (Copper Contributor)
Solution

@szub_2 -

 

If you're willing to try Power Query this can easily be done. This post describes the method https://excelgorilla.com/power-bi/power-query/reach-underlying-rows-using-table-max/.

 

1.png

@szub_2 

If with formulas

image.png

in P4

=IFERROR(INDEX($H$4:$H$12,AGGREGATE(15,6,1/(COUNTIF($P$3:P3,$H$4:$H$12)=0)*(ROW($H$4:$H$12)-ROW($H$3)),1)),"")

in K4

=IF(LARGE($C$4:$C$12*($H$4:$H$12=$P4),1)>1,LARGE($C$4:$C$12*($H$4:$H$12=$P4),1),"")

in J4

=IFNA(INDEX($B$4:$B$12,MATCH(1,INDEX(($H$4:$H$12=$P4)*($C$4:$C$12=$K4),0),0)),"")

and in the rest of the columns similar to J4. After that drag J4:P4 down.

@ChrisMendoza,

Thank you for the reply.  Would you be willing to provide a screen shot of how you did the grouping?  I reviewed the post you provided and I am not getting the same result.

 

Thanks again.

@szub_2 -

 

Sure thing.

 

2.png3.png4.png

@ChrisMendoza,

Thank you.  I worked through this and now I am not sure this approach will work as I have seem to have a lot of duplicates for transactions on the same day for the same serial number in my data, which is what I was trying to avoid. I will definitely keep this approach in mind for other projects.

 

Thanks for you assistance.

1 best response

Accepted Solutions
best response confirmed by szub_2 (Copper Contributor)
Solution

@szub_2 -

 

If you're willing to try Power Query this can easily be done. This post describes the method https://excelgorilla.com/power-bi/power-query/reach-underlying-rows-using-table-max/.

 

1.png

View solution in original post