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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
IDAronson
New Member

How to create a check column to identify duplicated composite values in a single data set

Hello.

 

I have been tossed a project that I feel a little in over my head on. I have been trying to puzzle this out today, I feel like I am starting to understand some of what I need to do. But part of it escapes me. Simply comparing has been easy to figure out. But having to look at this as a composite value is throwing me. Any tips, help or otherwise is very much appreciated. I have a set of data that has a series of ID numbers and a corresponding Text field. 

What I am attempting to do, is create a check column that will help me identify duplicated combination values. So for each Pair, I want to know if there is another identical pair within the data set. 

So for each row. It needs to look at the Number value and the Text. Then for each time the same number value is present. It needs to check if that first text was also present. If it is, I would like it to indicate that with a True False. Something like that. Lets say this first table is an example. The combination of Number = 1 and Text = Text 1 occurs twice. In my first row and my 5th row. So next to each of those rows, in my new column I would want it to display True. Any others that don't match it can say false.

NumberText
1

Text 1

2

Text 2

3Text 3
4Text 4
1

Text 1

2Text 1
3Text 3
4Text 2
1Text 3

 

Ideally looking something like this. Row 1 matches Row 5, so they are true. Row 3 matches with row 7, so they are true as well.

 

NumberTextDuplicate
1Text 1True
2Text 2False
3Text 3True
4Text 4False
1Text 1True
2Text 1False
3Text 3True
4Text 2False
1Text 3False
1 ACCEPTED SOLUTION
v-jialluo-msft
Community Support
Community Support

Hi @IDAronson ,

 

 @FreemanZ  was basically right, but there were some minor mistakes

 

 

Duplicate = 
VAR CurrentText='Table'[text]
VAR CurrentNumber='Table'[number]
VAR _count = COUNTROWS(
    FILTER(
        'Table', 
        'Table'[number]=CurrentNumber && 'Table'[text]=CurrentText
    )
)
RETURN
    IF(_count>=2, true, false)

 

 

vjialluomsft_0-1668496223520.png

 

Best Regards,

Gallen Luo

 

View solution in original post

5 REPLIES 5
v-jialluo-msft
Community Support
Community Support

Hi @IDAronson ,

 

 @FreemanZ  was basically right, but there were some minor mistakes

 

 

Duplicate = 
VAR CurrentText='Table'[text]
VAR CurrentNumber='Table'[number]
VAR _count = COUNTROWS(
    FILTER(
        'Table', 
        'Table'[number]=CurrentNumber && 'Table'[text]=CurrentText
    )
)
RETURN
    IF(_count>=2, true, false)

 

 

vjialluomsft_0-1668496223520.png

 

Best Regards,

Gallen Luo

 

Thank you so much. Appreciate the help. Now I need to make sure I fully understand how this works so that I can do it myself next time.

Aha, thanks for pointing out. FILTER can't take logic test argument like that. 

 

It needs to be:

'Table'[number]=CurrentNumber && 'Table'[text]=CurrentText

or 

AND(Data[Number]=CurrentNumber, Data[Text]=CurrentText))

 

Listing multiple logic test arguments is more common with CALCULATE.

FreemanZ
Super User
Super User

Supposing your table named Data, try to add a column with the code below:
Duplicate = 
VAR CurrentText=Data[Text]
VAR CurrentNumber=Data[Number]
VAR _count = COUNTROWS(
    FILTER(
        Data, 
        Data[Number]=CurrentNumber,
        Data[Text]=CurrentText
    )
)
RETURN
    IF(_count>=2, true, false)

Thanks for the help. This got me close. Then with Gallen's help that took me the rest of the way. Appreciate your help.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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