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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
mclawler
Helper III
Helper III

How to exclude duplicate values

Hi there, I am trying to remove duplicate transactions and keep a certain type.  

I need the Customer Count to equal 22 and the Amount Sum to equal $110,500

 

The logic should be:

If the same "Customer Number" appears > 1 time then it needs to only Count the Customer Number with the Product "Personal Line"  &&

If the same "Customer Number" appears > 1 time then it needs to only Sum the Amount with the Product "Personal Line"

 

It almost needs a temp table with the duplicate data stripped out of it?  Because ultimately it then becomes separated into groups for a matrix table(the image below isn't accurate):

mclawler_0-1725659824828.png

 

Here is the table data.  Basically keep the green and strip out the red because of the duplicate Customer Number:

mclawler_1-1725659891046.png

 

Thank you! 

1 ACCEPTED SOLUTION

Check Measure and Measure2.  File attached.

Ashish_Mathur_0-1725926302407.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

12 REPLIES 12
Anonymous
Not applicable

Hi ALL,
Firstly, Ashish_Mathur Thank you for your solution!
And @mclawler  ,you can use measure to write down the requirements you need to implement, and then aggregate them into a new table using summarize. 

CALCULATE(SUM(PCL_Data[Amount]),ALLEXCEPT(PCL_Data,'PCL_Data'[Customer Number])) 

 

We can use the rankx function to determine the first of the duplicate values as the return value,Fistly product As long as it is similar to Fistly pcl, you can change a few parameters.

FirstPCLMeasure = 
IF(
   CALCULATE(COUNTROWS('PCL_Data'), ALLEXCEPT('PCL_Data', 'PCL_Data'[Customer Number])) > 1,
   CALCULATE(
       MAX('PCL_Data'[PCL Increase/PCL New]),
       FILTER(
           'PCL_Data',
           'PCL_Data'[Customer Number] = MAX('PCL_Data'[Customer Number]) &&
           RANKX(
               FILTER('PCL_Data', 'PCL_Data'[Customer Number] = MAX('PCL_Data'[Customer Number])),
               'PCL_Data'[PCL Increase/PCL New],
               ,
               ASC
           ) = 1
       )
   ),
  MAX('PCL_Data'[PCL Increase/PCL New])
)

vxingshenmsft_0-1725874160751.png

Finally in the aggregation by summarize to form a new table, the design of their own matrix

 

Table = 
SUMMARIZE('PCL_Data','PCL_Data'[Customer Number],"Amount",'PCL_Data'[measure],"A",'PCL_Data'[FirstPCLMeasure],"B",'PCL_Data'[FirstProductMeasure])

vxingshenmsft_1-1725874202249.png

If you still have questions, check out my pbix file, I hope it helps!

 

 

Hope it helps!

 

Best regards,
Community Support Team_ Tom Shen

 

If this post helps then please consider Accept it as the solution to help the other members find it more quickly.

 

 

H! Those measures aren't working for what I'm trying to accomplish.  I have created 2 measures that get me the correct grand totals, but the row items are still incorrect.

 

mclawler_0-1725909660183.png

 

The Existing PCL Increase is correct = 5 units for $10,000

The New PCL is incorrect, should = 17 units for $102,500

 

I have created a pbix for testing here : PCL Testing.pbix

 

If the SAME Member Number appears for both Existing and New, I need the measure to strip out the data rows pertaining to the New PCL redundant Member Number.  This visual might make it clearer.  Include all black and green(duplicate member number), exclude the red:


Member NumberProductAmount BookedFundedDatePCL Increase/PCL New
1110410PERSONAL CREDIT LINE$9,500.0029-Jul-24New PCL
1239460PERSONAL CREDIT LINE$10,000.0022-Jul-24New PCL
1472450Personal Line$5,000.0010-Jul-24Existing PCL Increase
1596150PERSONAL CREDIT LINE$14,000.0011-Jul-24New PCL
2316130PERSONAL CREDIT LINE$7,000.0011-Jul-24New PCL
2588730Personal Line$1,500.006-Jul-24Existing PCL Increase
2588730PERSONAL CREDIT LINE$1,500.006-Jul-24New PCL
3215470PERSONAL CREDIT LINE$4,500.0031-Jul-24New PCL
3574660PERSONAL CREDIT LINE$5,000.0024-Jul-24New PCL
3697240PERSONAL CREDIT LINE$4,000.0030-Jul-24New PCL
4338890PERSONAL CREDIT LINE$5,000.001-Jul-24New PCL
4562300PERSONAL CREDIT LINE$5,000.0024-Jul-24New PCL
5563620Personal Line$500.0030-Jul-24Existing PCL Increase
5563620PERSONAL CREDIT LINE$500.0030-Jul-24New PCL
5648730PERSONAL CREDIT LINE$10,000.0023-Jul-24New PCL
6546300PERSONAL CREDIT LINE$1,000.0018-Jul-24New PCL
7412220PERSONAL CREDIT LINE$10,000.0029-Jul-24New PCL
7536160PERSONAL CREDIT LINE$2,500.002-Jul-24New PCL
7898990PERSONAL CREDIT LINE$2,000.0024-Jul-24New PCL
8523290Personal Line$1,000.0017-Jul-24Existing PCL Increase
8979840PERSONAL CREDIT LINE$500.0030-Jul-24New PCL
9514250Personal Line$2,000.0010-Jul-24Existing PCL Increase
9632420PERSONAL CREDIT LINE$10,000.0031-Jul-24New PCL
9873000PERSONAL CREDIT LINE$500.0024-Jul-24New PCL
Ashish_Mathur
Super User
Super User

Hi,

Why should the answer be 110,500?  Share data in a format that can be pasted in an MS Excel file.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

H! I have created 2 measures that get me the correct grand totals, but the row items are still incorrect.

 

mclawler_0-1725909660183.png

 

The Existing PCL Increase is correct = 5 units for $10,000

The New PCL is incorrect, should = 17 units for $102,500

 

I have created a pbix for testing here : PCL Testing.pbix

 

If the SAME Member Number appears for both Existing and New, I need the measure to strip out the data rows pertaining to the New PCL redundant Member Number.  This visual might make it clearer.  Include all black and green(duplicate member number), exclude the red:


Member NumberProductAmount BookedFundedDatePCL Increase/PCL New
1110410PERSONAL CREDIT LINE$9,500.0029-Jul-24New PCL
1239460PERSONAL CREDIT LINE$10,000.0022-Jul-24New PCL
1472450Personal Line$5,000.0010-Jul-24Existing PCL Increase
1596150PERSONAL CREDIT LINE$14,000.0011-Jul-24New PCL
2316130PERSONAL CREDIT LINE$7,000.0011-Jul-24New PCL
2588730Personal Line$1,500.006-Jul-24Existing PCL Increase
2588730PERSONAL CREDIT LINE$1,500.006-Jul-24New PCL
3215470PERSONAL CREDIT LINE$4,500.0031-Jul-24New PCL
3574660PERSONAL CREDIT LINE$5,000.0024-Jul-24New PCL
3697240PERSONAL CREDIT LINE$4,000.0030-Jul-24New PCL
4338890PERSONAL CREDIT LINE$5,000.001-Jul-24New PCL
4562300PERSONAL CREDIT LINE$5,000.0024-Jul-24New PCL
5563620Personal Line$500.0030-Jul-24Existing PCL Increase
5563620PERSONAL CREDIT LINE$500.0030-Jul-24New PCL
5648730PERSONAL CREDIT LINE$10,000.0023-Jul-24New PCL
6546300PERSONAL CREDIT LINE$1,000.0018-Jul-24New PCL
7412220PERSONAL CREDIT LINE$10,000.0029-Jul-24New PCL
7536160PERSONAL CREDIT LINE$2,500.002-Jul-24New PCL
7898990PERSONAL CREDIT LINE$2,000.0024-Jul-24New PCL
8523290Personal Line$1,000.0017-Jul-24Existing PCL Increase
8979840PERSONAL CREDIT LINE$500.0030-Jul-24New PCL
9514250Personal Line$2,000.0010-Jul-24Existing PCL Increase
9632420PERSONAL CREDIT LINE$10,000.0031-Jul-24New PCL
9873000PERSONAL CREDIT LINE$500.0024-Jul-24New PCL

Because the 2 I need removed are technically duplicates.  Which would leave 22 units for $110,500 as the correct Totals.  Thank you for your help!

 

Member NumberProductAmount BookedFundedDatePCL Increase/PCL New
1110410PERSONAL CREDIT LINE$9,500.0029-Jul-24New PCL
1239460PERSONAL CREDIT LINE$10,000.0022-Jul-24New PCL
1472450Personal Line$5,000.0010-Jul-24Existing PCL Increase
1596150PERSONAL CREDIT LINE$14,000.0011-Jul-24New PCL
2316130PERSONAL CREDIT LINE$7,000.0011-Jul-24New PCL
2588730Personal Line$1,500.006-Jul-24Existing PCL Increase
2588730PERSONAL CREDIT LINE$1,500.006-Jul-24New PCL
3215470PERSONAL CREDIT LINE$4,500.0031-Jul-24New PCL
3574660PERSONAL CREDIT LINE$5,000.0024-Jul-24New PCL
3697240PERSONAL CREDIT LINE$4,000.0030-Jul-24New PCL
4338890PERSONAL CREDIT LINE$5,000.001-Jul-24New PCL
4562300PERSONAL CREDIT LINE$5,000.0024-Jul-24New PCL
5563620Personal Line$500.0030-Jul-24Existing PCL Increase
5563620PERSONAL CREDIT LINE$500.0030-Jul-24New PCL
5648730PERSONAL CREDIT LINE$10,000.0023-Jul-24New PCL
6546300PERSONAL CREDIT LINE$1,000.0018-Jul-24New PCL
7412220PERSONAL CREDIT LINE$10,000.0029-Jul-24New PCL
7536160PERSONAL CREDIT LINE$2,500.002-Jul-24New PCL
7898990PERSONAL CREDIT LINE$2,000.0024-Jul-24New PCL
8523290Personal Line$1,000.0017-Jul-24Existing PCL Increase
8979840PERSONAL CREDIT LINE$500.0030-Jul-24New PCL
9514250Personal Line$2,000.0010-Jul-24Existing PCL Increase
9632420PERSONAL CREDIT LINE$10,000.0031-Jul-24New PCL
9873000PERSONAL CREDIT LINE$500.0024-Jul-24New PCL

Check Measure and Measure2.  File attached.

Ashish_Mathur_0-1725926302407.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thanks Ashish!!  I ended up using a slightly modified version of your EARLIER measure.  I added an additional EARLIER statement so that IF the same Member # AND the same Date were posted previously, then they were exlcuded.  This gave me the ability to aggregate/slice by month.  

 

Thank you!!!! 

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi Ashish!  When I input your calclulated column and those 2 measures I get a variance with New PCL.  Would EARLIER not work since my real pbix has months/years worth of previous data?  Should my measures relate to the monthly date table slicer somehow?  I'm not sure where to go from here. 

mclawler_0-1725929214024.png

The Consider? calculated column is only counting/summing 8 of the Member Numbers for PERSONAL CREDIT LINE:

ProductAmount BookedFundedDateFundedDateMonthPCL Increase/PCL NewPCL Consider?
Personal Line$5,000.0010-Jul-247/1/2024 0:00Existing PCL Increase1
Personal Line$1,000.0017-Jul-247/1/2024 0:00Existing PCL Increase1
Personal Line$2,000.0010-Jul-247/1/2024 0:00Existing PCL Increase1
Personal Line$1,500.006-Jul-247/1/2024 0:00Existing PCL Increase1
Personal Line$500.0030-Jul-247/1/2024 0:00Existing PCL Increase1
PERSONAL CREDIT LINE$14,000.0011-Jul-247/1/2024 0:00New PCL0
PERSONAL CREDIT LINE$10,000.0022-Jul-247/1/2024 0:00New PCL0
PERSONAL CREDIT LINE$500.0030-Jul-247/1/2024 0:00New PCL0
PERSONAL CREDIT LINE$500.0024-Jul-247/1/2024 0:00New PCL0
PERSONAL CREDIT LINE$4,000.0030-Jul-247/1/2024 0:00New PCL0
PERSONAL CREDIT LINE$500.0030-Jul-247/1/2024 0:00New PCL0
PERSONAL CREDIT LINE$10,000.0029-Jul-247/1/2024 0:00New PCL1
PERSONAL CREDIT LINE$2,500.002-Jul-247/1/2024 0:00New PCL0
PERSONAL CREDIT LINE$10,000.0023-Jul-247/1/2024 0:00New PCL1
PERSONAL CREDIT LINE$5,000.0024-Jul-247/1/2024 0:00New PCL1
PERSONAL CREDIT LINE$5,000.0024-Jul-247/1/2024 0:00New PCL1
PERSONAL CREDIT LINE$5,000.001-Jul-247/1/2024 0:00New PCL0
PERSONAL CREDIT LINE$1,000.0018-Jul-247/1/2024 0:00New PCL0
PERSONAL CREDIT LINE$2,000.0024-Jul-247/1/2024 0:00New PCL1
PERSONAL CREDIT LINE$9,500.0029-Jul-247/1/2024 0:00New PCL1
PERSONAL CREDIT LINE$4,500.0031-Jul-247/1/2024 0:00New PCL0
PERSONAL CREDIT LINE$7,000.0011-Jul-247/1/2024 0:00New PCL1
PERSONAL CREDIT LINE$10,000.0031-Jul-247/1/2024 0:00New PCL1
PERSONAL CREDIT LINE$1,500.006-Jul-247/1/2024 0:00New PCL0

As seen in my previous screenshot and file, i got the exact result you wanted.  Now i do no know what you want.  Someone who understands your question will help.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Almost there.  How do I get your Calculated column to dynamically calculate based on the Slicer(date table) selection?

 

Consider? = if(CALCULATE(COUNTROWS('PwBi LoanData'),FILTER('PwBi LoanData','PwBi LoanData'[Member Number]=EARLIER('PwBi LoanData'[Member Number])))>1,if('PwBi LoanData'[Product] = "Personal Line",1,0),1)
 
I keep reading about SELECTEDVALUE but I can't get it to work.  
 
Basically, I want that calculated column to "refresh" dynamically based on the Month chosen within my slicer.  This way it won't take into calculation the last 50 years of data, only the selected month at any given time.
 
mclawler_0-1726089766680.png

 

 

PBI file attached.

Hope this helps.

Ashish_Mathur_0-1726110986385.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.