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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

How to list duplicates in each of the rows in new column?

Hello,

I have encountered some challenges in attempting to achieve the following task. Identifying duplicates becomes straightforward when considering entire columns, but my objective is to identify duplicates from Column A within each individual row seperated by commas. Is this achievable using Power BI DAX? The desired results are outlined below. Please note that Column A is a calculated column, and we are restricted from making modifications in M.

ADuplicates
a,b,b,cb
a,a,b,b,c,ca,b,c
a,b,c 
a,a,ba

 

Any help is greatly appreciated, thank you so much. 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Thank you! I tried but it is showing error for [Name] at the very last line.

 

JOO13_0-1705992464081.png
I modified a little and it works! 

All Duplicates =
VAR CurrentItem = [A]
VAR WorkItem = SUBSTITUTE(CurrentItem, ",", "|")
VAR Qty = LEN(CurrentItem) - LEN(SUBSTITUTE(CurrentItem, ",", "")) + 1
VAR _tbl = GENERATESERIES(1, Qty)
VAR _tbl2 = ADDCOLUMNS(_tbl,
                       "Name",
                       PATHITEM(WorkItem, [Value]))
VAR _tbl3 = SUMMARIZE(_tbl2, [Name],
                      "Qty",
                      VAR CurrentName = [Name]
                      RETURN COUNTROWS(FILTER(_tbl2, [Name] = CurrentName)))
VAR DuplicatesList = CONCATENATEX(FILTER(_tbl3, [Qty] > 1), [Name], ",")
RETURN DuplicatesList

 

View solution in original post

3 REPLIES 3
barritown
Super User
Super User

Hi @Anonymous,

I guess the proper approach is to use Power Query and @ThxAlot's solution, but here's a DAX way to solve this:

barritown_0-1705930362064.png

The same in plain text:

Duplicates = 
VAR CurrentItem = [A]
VAR WorkItem = SUBSTITUTE ( CurrentItem, ",", "|" )
VAR Qty = LEN ( CurrentItem ) - LEN ( SUBSTITUTE ( CurrentItem, ",", "" ) ) + 1
VAR _tbl = GENERATESERIES ( 1, Qty )
VAR _tbl2 = ADDCOLUMNS ( _tbl, 
                         "Name", 
                         PATHITEM ( WorkItem, [Value] ) )
VAR _tbl3 = SUMMARIZE ( _tbl2, [Name],
                         "Qty", 
                         VAR CurrentName = [Name]
                         RETURN COUNTROWS ( FILTER ( _tbl2, [Name] = CurrentName ) ) )
RETURN CONCATENATEX ( SELECTCOLUMNS ( FILTER ( _tbl3, [Qty] > 1 ), [Name] ), [Name], "," ) 

 

Best Regards,

Alexander

My YouTube vlog in English

My YouTube vlog in Russian

Anonymous
Not applicable

Thank you! I tried but it is showing error for [Name] at the very last line.

 

JOO13_0-1705992464081.png
I modified a little and it works! 

All Duplicates =
VAR CurrentItem = [A]
VAR WorkItem = SUBSTITUTE(CurrentItem, ",", "|")
VAR Qty = LEN(CurrentItem) - LEN(SUBSTITUTE(CurrentItem, ",", "")) + 1
VAR _tbl = GENERATESERIES(1, Qty)
VAR _tbl2 = ADDCOLUMNS(_tbl,
                       "Name",
                       PATHITEM(WorkItem, [Value]))
VAR _tbl3 = SUMMARIZE(_tbl2, [Name],
                      "Qty",
                      VAR CurrentName = [Name]
                      RETURN COUNTROWS(FILTER(_tbl2, [Name] = CurrentName)))
VAR DuplicatesList = CONCATENATEX(FILTER(_tbl3, [Qty] > 1), [Name], ",")
RETURN DuplicatesList

 

ThxAlot
Super User
Super User

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WStRJAsJkpVgdEBvKg/NRZJRiYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Str = _t]),
    #"Added Dupliate" = Table.AddColumn(Source, "Dup", each let l = Text.Split([Str], ",") in Text.Combine(List.Distinct(List.Select(l, each List.Count(List.PositionOf(l, _, Occurrence.All))>1)), ","))
in
    #"Added Dupliate"

ThxAlot_0-1705920579432.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LearnAndPractise(Everyday)


)



Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors