Forum Discussion

An_dy's avatar
An_dy
Frequent Visitor
3 years ago
Solved

Find first values per ID and earliest Date

Hi All,

 

I am attempting to retrieve the earliest record for several data points within my table per ID. The bolded lines in the data below is what information I am interested in. I want to put this in to a table. When I do this with the current data set and I add values it shows the First or Last per value. The ID column is in the row section and Name/Company/etc is in the values section. "First" and "Last" in this context appears to be alphabetical. I want the first based on the DOS column. 

 

I have seen a few other posts discussing adding a calculated column and using Minx to find that information but so far I haven't been able to get that to work correctly. 

 

Example of data

 

IDName1Name2CompanyDOS
555123Smith, RichardDoe, JohnArizona5/1/2022
555123Smith, RichardName, MaryNew Mexico3/22/2023
223441Denis, RodgersRed, JohnArizona1/5/2021
223441Denis, RodgersAbdulla, DennisArizona1/10/2022
333422Johson, SamRiley, RicardoTexas1/3/2021
333422Johson, SamFunk, JimArizona1/22/2021
333422Johson, SamThompson, TonyaColorado9/3/2022

 

The rows outside of the bolded rows I would not be intersted in showing at all on the table. I want the final table to look like below. 

 

IDName1Name2CompanyDOS
555123Smith, RichardDoe, JohnArizona5/1/2022
223441Denis, RodgersRed, JohnArizona1/5/2021
333422Johson, SamRiley, RicardoTexas1/3/2021

 

I think I need a calculated column or measure for each data point (Name1, Name2, etc) based on the EARLIEST DOS by each Unique ID. 

 

Any help to point me in the right direction would be greatly appreciated. 

 

Thanks,

  • Hi An_dy
    To perform the filter you are interested in.
    In the first step, you can add a ranking column to your data table.
    In order of date, rank each ID
    DAx formula ;

    Ranking = RANKX(FILTER('Table','Table'[ID]=EARLIER('Table'[ID])),'Table'[DOS],,ASC)

     

    You filter the table by the column you added when you display it. The value of 1

    Link to sample file 

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

     



3 Replies

  • Hi An_dy
    To perform the filter you are interested in.
    In the first step, you can add a ranking column to your data table.
    In order of date, rank each ID
    DAx formula ;

    Ranking = RANKX(FILTER('Table','Table'[ID]=EARLIER('Table'[ID])),'Table'[DOS],,ASC)

     

    You filter the table by the column you added when you display it. The value of 1

    Link to sample file 

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

     



    • An_dy's avatar
      An_dy
      Frequent Visitor

      Hey that solution works great - Thank you very much for your help!