Removing Duplicate Transactions While Keeping the Latest Entry

0 votes

Removing Duplicate Transactions While Keeping the Latest Entry
Your sales dataset contains duplicate transaction IDs due to incorrect data entry. You need to remove duplicates while keeping only the latest transaction per ID. How can you achieve this in Power Query or DAX while ensuring accuracy?

16 hours ago in Power BI by Evanjalin
• 17,020 points
19 views

1 answer to this question.

0 votes

An approach to eliminate duplicate transactions while retaining only the last one is either through Power Query or DAX.

Solution 1: Power Query (Preferred Data Cleaning)

Sorting Data by Transaction Date

Open Power Query Editor.

Sort the dataset based on Transaction ID (Ascending) and sort Transaction Date (Descending), which will bring the latest entry first.

Remove Duplicate, Keeping Latest Entry

Select the Transaction ID column,

Click Remove Duplicates from the Home ribbon.

This will result in Power Query keeping the first occurrence, which, in this case, is now the latest because of sorting.

Solution 2: DAX (For Dynamic Calculations in Reports)

If the dataset cannot be preprocessed, use a DAX measure or calculated table.

DAX Table (Filtered Latest Transactions)

Latest Transactions = 
VAR LatestDates = 
    ADDCOLUMNS( 
        SUMMARIZE( Sales, Sales[Transaction ID], "LatestDate", MAX( Sales[Transaction Date] ) ), 
        "LatestEntry", 
        LOOKUPVALUE( Sales[Transaction Date], Sales[Transaction ID], Sales[Transaction ID], Sales[Transaction Date], MAX( Sales[Transaction Date] ) )
    )
RETURN 
FILTER( Sales, Sales[Transaction Date] = [LatestEntry] )
  • This table keeps only the latest transaction per Transaction ID dynamically.

DAX Measure (For Reporting)

Latest Sales Amount = 
VAR LatestDate = MAX( Sales[Transaction Date] )
RETURN 
CALCULATE( SUM( Sales[Amount] ), Sales[Transaction Date] = LatestDate )

Ensures only the latest sales amounts are considered in reports.

answered 16 hours ago by anonymous
• 17,020 points

Related Questions In Power BI

+1 vote
1 answer

Show the latest value in PowerBi from ASA

Best you can do right now is ...READ MORE

answered Oct 25, 2018 in Power BI by Surendra
1,679 views
0 votes
1 answer
0 votes
0 answers
+2 votes
0 answers

Assume referential integrity

1) What is Assume referential integrity? what ...READ MORE

Aug 19, 2019 in Power BI by vnk
1,912 views
+2 votes
1 answer

If Condition

DAX - I assume [Claim_line].[Allowed_Amount_B6] is one ...READ MORE

answered Aug 20, 2019 in Power BI by anonymous
• 33,030 points
1,709 views
+2 votes
1 answer

How to export data to CSV from power bi embedded url ?

Hi Arathi, You can open Visuals from embedded ...READ MORE

answered Aug 23, 2019 in Power BI by anonymous
• 33,030 points
6,774 views
+1 vote
1 answer

Power Bi to Machine Learning Model

Hello @vnk! Power BI only supports Azure Machine ...READ MORE

answered Dec 3, 2019 in Power BI by Priyanka
1,285 views
0 votes
1 answer

What are the recommended ways to transfer data from Power BI to DOMO while maintaining performance and data integrity?

There are approaches to efficiently performing the ...READ MORE

answered Feb 24 in Power BI by anonymous
• 17,020 points
40 views
0 votes
1 answer

What is the best approach to convert a Date/Time column to a Date data type in Power Query while using DirectQuery from SQL?

For DirectQuery, the best way to convert ...READ MORE

answered 5 days ago in Power BI by anonymous
• 17,020 points
35 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP