Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Pick the latest record from source

I have data coming in from plant where sometimes they send updated information on a later time or updte the previous data if there was an error. How will I use Power Qury/PowerBI to pick the record with latest time.

Example

Record 1 time: 2020/08/24 17:20:00
Record 2 time: 2020/08/24 19:20:00

I want to pick the one that was sent at 19:20 and reject the record that was sent earlier

Attaching a sample for reference

Plant TransactionDate Produced Defcts rejected Audited
PE 2020/08/24 17:20:00 70 5 1 1
PE 2020/08/24 19:20:00 60 9 1 1
PTA 2020/08/21 16:25:00 20 1 0 0
PTA 2020/08/22 19:20:00 30 0 0 1
PTA 2020/09/07 10:00:00 120 5 5 0
PTA 2020/09/07 20:00:00 90 0 0 1

 

 


Thanks in advance.

 

 

  • Fowmy's avatar
    Fowmy
    5 years ago

    Anonymous 

    In this case, no need to create a new table, you can add a new column to your table with the following code:

    You can download the file: HERE

     

    ________________________

    If my answer was helpful, please consider Accept it as the solution to help the other members find it

    Click on the Thumbs-Up icon if you like this reply 🙂

    YouTube  LinkedIn

     

7 Replies

  • Anonymous 

    Go to ModlingTab > New Table and paste the code, it will give you a new table with the latest records:

    Table = 
    FILTER(
        Table,
        VAR _MaxDate = CALCULATE( MAX(Table[TransactionDate]),ALLEXCEPT(Table,Table[Plant])) RETURN
        Table[TransactionDate] = _MaxDate
    )

     

    ________________________

    If my answer was helpful, please consider Accept it as the solution to help the other members find it

    Click on the Thumbs-Up icon if you like this reply 🙂

    YouTube  LinkedIn

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank You Fowmy 

       

      I am a newbie and if you can give me the sample PBIX, that will be kind of you. Still trying to apply what you asked

       

      PlantTransactionDateProducedDefctsrejectedAudited
      PE2020/08/24 17:20:0070511
      PE2020/08/24 19:20:0060911
      PTA2020/08/21 16:25:0020100
      PTA2020/08/22 19:20:0030001
      PTA2020/09/07 10:00:00120550
      PTA2020/09/07 20:00:0090001

       

       

      • Fowmy's avatar
        Fowmy
        Icon for Super User rankSuper User

        Anonymous 

         

        You can download the file: HERE

        ________________________

        If my answer was helpful, please consider Accept it as the solution to help the other members find it

        Click on the Thumbs-Up icon if you like this reply 🙂

        YouTube  LinkedIn