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
Anonymous
Not applicable

Row Count Line Idenification

This is an example of of 1 invoice with 1 line item that was split into 5, I want to remove all the Duplicates and just have 1 line. 

Document IDInvoice NumberLine NumberLine AmountInvoice Total

What I want the Results to be

123456784010

1

1095First
12345678401011095Duplicate
12345678401011595Duplicate
12345678401012095Duplicate
12345678401014095Duplicate

 

1 ACCEPTED SOLUTION
v-kelly-msft
Community Support
Community Support

Hi @Anonymous ,

 

Use below M codes:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyNjE1M7dQ0lEyMTA0AFKGIAxiWJoqxepQoMKUkAojgmaYwFTEAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Document ID" = _t, #"Invoice Number" = _t, #"Line Number" = _t, #"Line Amount" = _t, #"Invoice Total" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Document ID", Int64.Type}, {"Invoice Number", Int64.Type}, {"Line Number", Int64.Type}, {"Line Amount", Int64.Type}, {"Invoice Total", Int64.Type}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Custom", each Table.Min(Table.SelectRows(#"Added Index",each [Document ID]=[Document ID] and [Invoice Number]=[Invoice Number] and [Line Number]=[Line Number] and [Line Amount]=[Line Amount] and [Invoice Total]=[Invoice Total]),"Index")),
    #"Expanded Custom" = Table.ExpandRecordColumn(#"Added Custom", "Custom", {"Index"}, {"Custom.Index"}),
    #"Added Custom1" = Table.AddColumn(#"Expanded Custom", "Custom", each if [Index]=[Custom.Index] then "First" else "Duplicated"),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Custom.Index", "Index"})
in
    #"Removed Columns"

And you will see:

vkellymsft_0-1624603459612.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

View solution in original post

3 REPLIES 3
v-kelly-msft
Community Support
Community Support

Hi @Anonymous ,

 

Use below M codes:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQyNjE1M7dQ0lEyMTA0AFKGIAxiWJoqxepQoMKUkAojgmaYwFTEAgA=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Document ID" = _t, #"Invoice Number" = _t, #"Line Number" = _t, #"Line Amount" = _t, #"Invoice Total" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Document ID", Int64.Type}, {"Invoice Number", Int64.Type}, {"Line Number", Int64.Type}, {"Line Amount", Int64.Type}, {"Invoice Total", Int64.Type}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type),
    #"Added Custom" = Table.AddColumn(#"Added Index", "Custom", each Table.Min(Table.SelectRows(#"Added Index",each [Document ID]=[Document ID] and [Invoice Number]=[Invoice Number] and [Line Number]=[Line Number] and [Line Amount]=[Line Amount] and [Invoice Total]=[Invoice Total]),"Index")),
    #"Expanded Custom" = Table.ExpandRecordColumn(#"Added Custom", "Custom", {"Index"}, {"Custom.Index"}),
    #"Added Custom1" = Table.AddColumn(#"Expanded Custom", "Custom", each if [Index]=[Custom.Index] then "First" else "Duplicated"),
    #"Removed Columns" = Table.RemoveColumns(#"Added Custom1",{"Custom.Index", "Index"})
in
    #"Removed Columns"

And you will see:

vkellymsft_0-1624603459612.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

Anonymous
Not applicable

In the formula bar:= Table.RemoveDuplicates(NameOfPriorStep,{"DocumentID"})

--Nate

Anonymous
Not applicable

Instead of remove the Duplicates I want to Identify the Duplicate.

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.