cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Frequent Visitor

Count duplicates with having constraint

I am working with data quality visualization and trying to count for duplicates with a filter and not seeing how to accomplish.  Below is some made up data that should help explain issue:

 

BrandChildParentsurrogate
ST1A123
ST2A123
ST3B456
ST4B789
LR5C567
LR6C890

 

First I need a filter for just Brand = ST, then for those that pass the filter I need validate a rule of each Parent has one Surrogate.

This is what I am looking for as Brand LR is not relevant thus Duplicate = NA, Parent A passes the duplicate rule since there is only one surrogate and Parent B Fails because there are multiple surrogates.

BrandChildParentsurrogateDuplicate
ST1A123Pass
ST2A123Pass
ST3B456Failure
ST4B789Failure
LR5C567N/A
LR6C890N/A

 

I have tried both DAX and M (power query) and am not able to get desired resutls.

 

For M I referenced https://www.excelguru.ca/blog/2015/12/09/identify-duplicates-using-power-query/ .  This does not work because Parent A has multiple rows and it count this as a duplicate and for me it is not since it only has one Surrogate.

 

For DAX I referenced https://community.powerbi.com/t5/Desktop/Identify-duplicates-and-show-up-records/td-p/210061.  This does not work because my data set is large and it returns with out of memory error.

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Super User III
Super User III

Re: Count duplicates with having constraint

@bvanevr

 

Try This Calculated Column

 

Duplicates =
VAR mycount =
    CALCULATE (
        DISTINCTCOUNT ( TableName[surrogate] ),
        ALLEXCEPT ( TableName, TableName[Parent] )
    )
RETURN
    IF ( TableName[Brand] = "ST", IF ( mycount = 1, "Pass", "Failure" ), "N/A" )
Try my new Power BI game Cross the River

View solution in original post

3 REPLIES 3
Highlighted
Super User III
Super User III

Re: Count duplicates with having constraint

@bvanevr

 

Try This Calculated Column

 

Duplicates =
VAR mycount =
    CALCULATE (
        DISTINCTCOUNT ( TableName[surrogate] ),
        ALLEXCEPT ( TableName, TableName[Parent] )
    )
RETURN
    IF ( TableName[Brand] = "ST", IF ( mycount = 1, "Pass", "Failure" ), "N/A" )
Try my new Power BI game Cross the River

View solution in original post

Highlighted
Super User III
Super User III

Re: Count duplicates with having constraint

@bvanevr

 

7603.png

Try my new Power BI game Cross the River
Highlighted
Frequent Visitor

Re: Count duplicates with having constraint

You rock man.

 

I did not realize you could put a formula like that as a VAR.  It also does not impact user experience.

Helpful resources

Announcements
Community Blog

Community Blog

Visit our Community Blog for articles, guides, and information created by fellow community members.

Using the Community

Using the Community

Need help with the Power BI Community? Our 'Using the Community' support articles are a great place to start.

Galleries

Galleries

Looking for inspiration on how to present your data? Need instructional videos? Check out our Galleries!

Community Summit North America

Community Summit North America

Innovate, Collaborate, Grow. The top training and networking event across the globe for Microsoft Business Applications

Top Solution Authors
Top Kudoed Authors