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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
Mooihoek
Helper II
Helper II

Power BI Remove Duplcates based on measure value

I want to be able to remove some duplicate account numbers based on whether the account has expired or not.  I'm using the following measure to identify whether the acccount has expired in a table based in the account expiry date.

 

e.g. Account Expiry = DATEDIFF(TODAY(),MAX('Table1'[Account End Date]),DAY), this gives me a value in the Account Expiry Day column, I then want to remove 

 

As you can see by the below table, Account 2 appears twice, but only one is valid, e.g it has 10 days remaining (the other expired 35 days ago) . How can I remove the duplicates accounts which have expired?

 

Sales Account NameAccount Expiry (DaysAcount ExpiryAccount ID
Account 1-501/02/20181234
Account 2-351/05/201812345
Account 3-51/07/2018123456
Account 2101/08/201812345
Account 5151/09/201812345678
Account 6201/10/2018123456789

 

 

1 ACCEPTED SOLUTION

Hi Mooihoek,

 

Check if the calculate column below is what you want to achieve.

捕获.PNG 

 

Regards,

Jimmy Tao

View solution in original post

8 REPLIES 8
v-yuta-msft
Community Support
Community Support

Hi Mooihoek,

 

You can create a measure using DAX as below:

Result = CALCULATE(MAX(Table1[Account Expiry(Days)]), ALLEXCEPT(Table1, Table1[Sales Account Name]))

捕获.PNG 

PBIX file: https://www.dropbox.com/s/v7dfs2j8yff3tg5/Power%20BI%20Remove%20Duplcates%20based%20on%20measure%20v....

 

Regards,

Jimmy Tao

Many thanks Jimmy, doesnt appear to be working though, one thing that is different from your example is that my "Account Expiry" column is already a measure.  

 

 

Can I create a new column from the Account Expiry measure?  

Hi Mooihoek,

 

I have make a measure using Account Expiry(Days) column.

Account Expiry(Days) Measure = MAX(Table1[Account Expiry(Days)])

Then modify [Result] measure as below:

Result = CALCULATE([Account Expiry(Days) Measure], ALLEXCEPT(Table1, Table1[Sales Account Name]))

捕获.PNG 

 

Regards,

Jimmy Tao

Thats great thanks, noticed through it only works if the Account Expiry hasnt been added to the table, and I need the column. Any ideas on how to get around this?

 

 

 Account Expiry.png

Hi Mooihoek,

 

You should change [Account Expiry] as a column because calculate column can't based on aggregation value in DAX.

 

Regards,

Jimmy Tao

How would I change Account Expiry (which is a measure) to a normal column? 

Hi Mooihoek,

 

Check if the calculate column below is what you want to achieve.

捕获.PNG 

 

Regards,

Jimmy Tao

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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