Forum Discussion

rostromarre's avatar
rostromarre
Frequent Visitor
7 years ago
Solved

Finding the most recent date/time for each row

Hello all,

 

I have a table with a date/time column with differents values and i would like to keep only the latest value for each row . Bassicaly i have this:

 

a

 

and I would like to have the bellow result, based on the latest DATE/TIME

 

 

thanks in advance for your help

  • rostromarre

     

    My bad....Sorry i missed this point

     

    Try this. See the attached file as well

     

    Step 1: First Add a custom column to get the dates only without time.

    =Int64.From([Dates])

    Convert above integer to date format to get the date portion

     

     

    Step 2: Group by ID and this DateOnly Column with Max of DateTime Column and All other rows

    as follows



    Step # 3: Now we use Table.Max function to get the other rows
     Then expand table and remove unnecessary columns

6 Replies

    • rostromarre's avatar
      rostromarre
      Frequent Visitor

      I tried your idea  Zubair_Muhammad but i have a problem,

       

      The idea is to keep the max (date/time) for each day and for each 'id', not the max value of the whole column.

       

      Maybe i didn't explain well... this is my table :

       

      for Id=1 i have three values taken the 01/08/2018 and i should only keep the last one (01/08/2018 8:35:12), same rule for every id each day (in case i have more than one value for each id)

       

      • Zubair_Muhammad's avatar
        Zubair_Muhammad
        Icon for Community Champion rankCommunity Champion

        rostromarre

         

        My bad....Sorry i missed this point

         

        Try this. See the attached file as well

         

        Step 1: First Add a custom column to get the dates only without time.

        =Int64.From([Dates])

        Convert above integer to date format to get the date portion

         

         

        Step 2: Group by ID and this DateOnly Column with Max of DateTime Column and All other rows

        as follows



        Step # 3: Now we use Table.Max function to get the other rows
         Then expand table and remove unnecessary columns