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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
Mahi1989
Frequent Visitor

Remove duplicates values based on multiple column with a condition in query editor

Hi All, 

I am new to power bi and would require your help to sort out below issue which i am facing.

basically i am taking three columns into consideration as below

 

 

 

Question.JPG

 


Question: I would like to remove duplicate values from above table based on conditon "
Equal value for "Time" ,"ID" and Absolute difference in "Time spent" is lower or equal than 1"
as you can see in the image Rows highlighted falls in this category.

 

would like to get these below rows removed based upon condition.

 

Rows to be removed.JPG

 

 

And final solution should look like this:

Solution.JPG

 

 

I am able to perform this in excel by making us of a fourth column with formulae "=IF(AND(A3=A2,B3=B2,ABS(F3-F2)<1),"problem",0) " and then filtering out the rows marked as probelm.  Please help!!

 

Regards

Mahi

 

 

 

 

1 ACCEPTED SOLUTION
v-lili6-msft
Community Support
Community Support

Hi@Mahi1989

You use Merge Queries function in Edit Queries.

You can try to do it follow my steps:

Step 1:

Duplicate the data table as below

41.png

Step 2:

Add index column for two table

Basic table start from 1 and increment is  1

42.png

Duplicate table start from 0 and increment is  1

43.png

Step 3:

Merge two table

44.png

Step 4:

Expand the table and apply &close

45.png

Step 5:

Add column

Column = IF(Table4[Time]=Table4[Added Index.Time]&&Table4[ID]=Table4[Added Index.ID]&&ABS(Table4[Time Spent]-Table4[Added Index.Time Spent])<1,1,2)

Step 6:

Filter the table

46.png

 

Here is demo ,please try it.

.PBIX https://www.dropbox.com/s/05w8ln994lz0kwu/Remove%20duplicates%20values%20based%20on%20multiple%20col...

EXCEL  https://www.dropbox.com/s/gle4648a4c81kro/example.xlsx?dl=0

 

 

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-lili6-msft
Community Support
Community Support

Hi@Mahi1989

You use Merge Queries function in Edit Queries.

You can try to do it follow my steps:

Step 1:

Duplicate the data table as below

41.png

Step 2:

Add index column for two table

Basic table start from 1 and increment is  1

42.png

Duplicate table start from 0 and increment is  1

43.png

Step 3:

Merge two table

44.png

Step 4:

Expand the table and apply &close

45.png

Step 5:

Add column

Column = IF(Table4[Time]=Table4[Added Index.Time]&&Table4[ID]=Table4[Added Index.ID]&&ABS(Table4[Time Spent]-Table4[Added Index.Time Spent])<1,1,2)

Step 6:

Filter the table

46.png

 

Here is demo ,please try it.

.PBIX https://www.dropbox.com/s/05w8ln994lz0kwu/Remove%20duplicates%20values%20based%20on%20multiple%20col...

EXCEL  https://www.dropbox.com/s/gle4648a4c81kro/example.xlsx?dl=0

 

 

 

Best Regards,

Lin

Community Support Team _ Lin
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi Lin,

 

Thanks for saving my day it worked, cheers mate 🙂

 

Regards

Sumit

Seward12533
Solution Sage
Solution Sage

If you just want to exclude the data from your model entirely it is best to do it I. Power query before you load the data to your model. I’m on my phone so having you the walk trough of how to do this is difficult because I do t remember all the menu commands off the top of my head. But basically highlight those columns and under remove rows hit remove duplicates. You may also want to duplicate the query and keep only duplicates and return a problem table but not required if you don’t want to look at it.

You can do it in Dax but don’t recommend this unless you need all the data for other calculations since the Dax gets messy and requires the use of EARLIER which while easy is conceptually challenging. It’s hard in Dax since each cell is independently calculated and you can lookup the value in another cell.


Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Top Solution Authors