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
Anonymous
Not applicable

How to remove duplicate with if else condition

Hi all,

 

Want to ask how can I remove duplicate with if else condition? Do it have some formula for that?

 

Current data

nuhasan_4-1658475202240.png

 

 

Data that I want it to be view in powerbi

 

nuhasan_5-1658475242294.png

 

 

I try to remove duplicate the usage (unit) but there will be a possibility that the usage (unit) have same value on different day. (in this case 9 & 10).

So my idea is = if production order have duplicate value then remove duplicate usage (unit)

 

Any help?

 

Regards,

Nuha

 

 

 

7 REPLIES 7
stenford23
Helper I
Helper I

Can you explain more which rows you expect to drop or keep and why?

Anonymous
Not applicable

Hi @stenford23 ,

 

I want to drop the yellow highlighted row and remain the not highlighted row.

Because as you can see in the red highlighted data is different.

 

nuhasan_1-1658476888989.png

 

Regards,

Nuha

 

 

Table.Distinct(
    Table.Buffer(
		Table.Sort(
           original_table,
		   {"End Time", Order.Ascending}
		)
	), {"Usage (Unit)}"
)

 

 

Sort by End date (add start date also if you need it), Buffer it (otherwise it won't work) and get distinct.

Anonymous
Not applicable

Hi @stenford23 

 

I should try this method/code in advanced editor or how?

 

Regards,

Nuha

Yes @Anonymous  insert this code in advanced editor

replace original_table with previous step name

Anonymous
Not applicable

Hi @stenford23 ,

 

Sorry I dont quite understand. Please refer as below for my advanced editor

 

nuhasan_0-1658480933615.png

 

 

Regards,

Nuha

 

Replace the code i give to you with

 

drop_duplicates = Table.Distinct(
    Table.Buffer(
		Table.Sort(
           #"Expanded SAP__PPT_EV_ProductionOrderConfirmationAdd (3)",
		   {"End Time", Order.Ascending}
		)
	), {"Usage (Unit)}"
)

in 
   drop_duplicates

 

Change also what comes after "in" by replacing it with drop_duplicates (as in the code above)

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors