Forum Discussion

szub_2's avatar
szub_2
Copper Contributor
Jan 22, 2020
Solved

How to identify the most recent transaction

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.

  • 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/.

     

5 Replies

  • SergeiBaklan's avatar
    SergeiBaklan
    Diamond Contributor

    szub_2 

    If with formulas

    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's avatar
    ChrisMendoza
    Iron Contributor

    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/.

     

    • szub_2's avatar
      szub_2
      Copper Contributor

      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.

Resources