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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
EmmaLiuLiu
Helper I
Helper I

If duplicate, how to compare other columns?

Hi gurus:

 

I've been working on this since last night. I have this data table. The Key column is concat value of Plant, Material, Purchase Order and Item columns. If there are duplicates in column Key, it's "351" in column Movement Type, and the date in Posting Date is on the same or an earlier date than the other duplicate with "352" in column Movement Type, then mark "Delete", otherwise mark "Keep".

PlantMaterialMovement typePurchase orderItemkeyPosting Date
64170-810-030-80535140001210957064170-810-030-8054000121095703/13/2024
64170-810-030-80535240001210957064170-810-030-8054000121095703/13/2024
64170-810-033-42735140001210958064170-810-033-4274000121095808/8/2023
64170-810-034-51735140001210959064170-810-034-5174000121095908/7/2023
66020-810-015-65435140001219021066020-810-015-6544000121902109/5/2023
66020-810-015-65435140001219021066020-810-015-65440001219021011/8/2023

 

The final column I'd like to add is like this:

 

PlantMaterialMovement typePurchase orderItemkeyPosting DateAdded Column
64170-810-030-80535140001210957064170-810-030-8054000121095703/13/2024Delete
64170-810-030-80535240001210957064170-810-030-8054000121095703/13/2024Keep
64170-810-033-42735140001210958064170-810-033-4274000121095808/8/2023Keep
64170-810-034-51735140001210959064170-810-034-5174000121095908/7/2023Keep
66020-810-015-65435140001219021066020-810-015-6544000121902109/5/2023Keep
66020-810-015-65435140001219021066020-810-015-65440001219021011/8/2023Keep

 

Is it something achievable in power bi? 

1 ACCEPTED SOLUTION
muhammad_786_1
Super User
Super User

Hi @EmmaLiuLiu 

 

Does your data contain only Movement Types '351' and '352'

 

Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.


Best Regards,
Muhammad Yousaf

 

View solution in original post

8 REPLIES 8
muhammad_786_1
Super User
Super User

Hi @EmmaLiuLiu 

 

Does your data contain only Movement Types '351' and '352'

 

Can you please share a pbix or some dummy data that keep the raw data structure with expected results? It should help us clarify your scenario and test to coding formula.


Best Regards,
Muhammad Yousaf

 

Gsssidhu
Frequent Visitor

and its not a measure, you are creating a new column. let me know your table name so that i can post the exact DAX that you need to use.

Keep adding the condition in the filter function

Filter(
TableName,
TableName[Key] = Earlier(TableName[Key]) &&
TableName[Posting_Date] <= Earlier(TableName[Posting_Date])&&
TableName[Movement_Type] <> Earlier(TableName[Movement_Type])
)

It's still not working. I'm going to post my power bi desktop file here so you or other gurus can help test it out. Thanks again!

Gsssidhu
Frequent Visitor

Key Column, that is what you are looking for duplicates, Right?

I meant column, not meausre.

 

Unfortunately it doesn't work. It deleted all duplicate records. I only want these rows to be deleted:

 

  1. It has to be a duplicate in column Key
  2. Then the posting date of that row has to be on the same or an earlier date compared to the one in row with “352” in column “movement type”. In other words, if there is no 352, then keep the records. If there is 352, only delete the one that has a “no later posing date” record.

Can you please help me😩?

Gsssidhu
Frequent Visitor

 Try This

 

Duplicate_Flag
If
(
Countrows(
Filter(
TableName,
TableName[ColumnName] = Earlier(TableName[ColumnName])
)
)>1, "Delete", "Keep")

Thanks for the response @Gsssidhu ! 

 

I have all columns marked with names. So what's the "ColumnName" you were refering to in your meausre?

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

Check out the November 2025 Power BI update to learn about new features.

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors