Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

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

 

Chin_0-1599989470648.png

 


Thanks in advance.

 

 

1 ACCEPTED SOLUTION

@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

 

Fowmy_0-1599993997539.png

________________________

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

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

View solution in original post

7 REPLIES 7
Fowmy
Super User
Super User

@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

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

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

 

 

@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

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

Thank You Very Much for looking into this. Regret, I did not explain my requirements properly. Sorry about that

 

If on a particular day, there are 2 entries, I need to reject the old record and pick the latest record, all other records for previous dates will remain as is. To further clarify, the table below will help.

 

I will then use the records that says KEEP and pivot them.

 

PlantTransactionDateProducedDefctsrejectedAuditedKEEP OR REJECT
PE2020-08-24 17:20:0070511REJECT
PE2020-08-24 19:20:0060911KEEP
PTA2020-08-21 16:25:0020100KEEP
PTA2020-08-22 19:20:0030001KEEP
PTA2020-09-07 10:00:00120550REJECT
PTA2020-09-07 20:00:0090001KEEP
PE2020-09-07 10:00:0050000KEEP
PE2020-08-22 19:20:0020000KEEP

 

 

Regards.

@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

 

Fowmy_0-1599993997539.png

________________________

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

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Anonymous
Not applicable

Thanks a ton. Much appreciate your time and help. I was actually thinking that it can be done in PowerQuery but it is done in PowerBI.

 

Is there a formal training for PowerBI formulas that you just did that one can learn about from YouTube or some other forums?

@Anonymous 

I can direct you to a book by @Greg_Deckler  on multiple regular DAX pattershttps://www.amazon.com/gp/product/B085RM7C9J


And, you should not miss this: https://www.sqlbi.com/


Good luck!

________________________

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

 

Did I answer your question? Mark my post as a solution! and hit thumbs up


Subscribe and learn Power BI from these videos

Website LinkedIn PBI User Group

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.