Forum Discussion

MDO's avatar
MDO
Frequent Visitor
2 years ago
Solved

How to make a new column with latest data

Hi,

 

I want to make a new column for showing the latest bin code for each serial no - I cannot figure it out how to do it.

I have tried Group By in Power Query, but doesn't work.

 

I want something like below. The first 4 column are raw data, and the last are the data I need. 

Registering DateQuantitySerial No_Bin CodeLATEST BIN CODE
26-09-2023 00:001SN00001430601RENT-0253
26-10-2023 00:00-1SN000014TRANSITRENT-0253
27-09-2023 00:00-1SN00001430601RENT-0253
27-09-2023 00:001SN000014RENTALRENT-0253
26-10-2023 00:001SN000014RENT-0253RENT-0253
13-03-2023 00:00-1SN166TRANSITRENT-0188
03-02-2023 00:001SN166TRANSIT-REPRENT-0188
06-02-2023 00:00-1SN166TRANSIT-REPRENT-0188
06-02-2023 00:001SN166RENT-0188RENT-0188
27-02-2023 00:00-1SN166RENT-0188RENT-0188
13-03-2023 00:001SN0032970311RENT-0226
04-07-2023 00:001SN0032930601RENT-0226
13-06-2023 00:00-1SN0032970311RENT-0226
23-06-2023 00:00-1SN0032930601RENT-0226
23-06-2023 00:001SN0032911024RENT-0226
13-06-2023 00:001SN00329RENT-0226RENT-0226
04-07-2023 00:00-1SN00329RENT-0226RENT-0226
13-03-2023 00:001SN003657031111023
07-07-2023 00:00-1SN003657031111023
07-07-2023 00:001SN003651102311023
28-11-2022 00:00-1SN753TRANSITTRANSIT
15-02-2023 00:00-1SN753TRANSITTRANSIT
22-12-2022 00:001SN75321413TRANSIT
04-01-2023 00:00-1SN753TRANSITTRANSIT

 

 

I hope someone can help me 🙂 - Thank you in advance.

  • Hello MDO ,
    Please find attached file for your reference. But the output is not mentioned correctly as per your example because for serial number SN166 latest date is 13th March so the Latest Bin Code will be TRANSIT not RENT-0188. So these things are taken care in the attached eample. 
    DAX will be:

    Latest Bin Calculated = 
    Var One = CALCULATE(MAX('Table'[Registering Date]),ALLEXCEPT('Table','Table'[Serial No_]))
    Var Result = CALCULATE(MAX('Table'[Bin Code]),FILTER('Table','Table'[Registering Date] = One))
    Return
    Result

     Output looks as below:

     

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

     

4 Replies

  • Hello MDO ,
    Please find attached file for your reference. But the output is not mentioned correctly as per your example because for serial number SN166 latest date is 13th March so the Latest Bin Code will be TRANSIT not RENT-0188. So these things are taken care in the attached eample. 
    DAX will be:

    Latest Bin Calculated = 
    Var One = CALCULATE(MAX('Table'[Registering Date]),ALLEXCEPT('Table','Table'[Serial No_]))
    Var Result = CALCULATE(MAX('Table'[Bin Code]),FILTER('Table','Table'[Registering Date] = One))
    Return
    Result

     Output looks as below:

     

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

     

  • you wrote what you need
    like this
    09/26/2023 00:00 1 SN000014 30601 RENT-0253