Forum Discussion

neilmc's avatar
neilmc
Frequent Visitor
3 years ago
Solved

Filter rows by max date keeping ID

Hello I have the data below   Ideally I would like to select for each PerID the containing the latest date.  I've tried groupby in query editor (groupby perID then select Max date and all rows, how...
  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi neilmc ,

     

    According to your description, here are my steps you can follow as a solution.

    (1) My test data is the same as yours.

    (2) We can create a table.

    Table 2 = 
    var _a=ADDCOLUMNS('Table',"max", CALCULATE(MAX('Table'[StartDate]),FILTER('Table','Table'[PerID]=EARLIER('Table'[PerID]))))
    var _b= FILTER(_a,[StartDate]=[max]) 
    return SELECTCOLUMNS(_b,"PerID",[PerID],"DBID",[DBID],"StartDate",[StartDate])

    (3) Then the result is as follows.

     

    Best Regards,

    Neeko Tang

    If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly.