Forum Discussion
Compare Duplicate Row Contents
- Anonymous2 years ago
1.You can create a index column grouped by Document number field first, You can refer to the following link.
https://radacad.com/create-row-number-for-each-group-in-power-bi-using-power-query
2.Based on the fiest step, then create a custom column(the index column is created in the first step)
Table.SelectRows(#"Expanded Table",(x)=>x[Document number]=[Document number] and x[Index]=1)3.Based on the first step, then create a custom column
if [Index]=1 then null else if List.Min([Custom][Title])<>[Title] then "Title Changed" else if List.Min([Custom][Name])<>[Name] then "Name Changed" else if List.Min([Custom][Name])<>[Name] and List.Min([Custom][Title])<>[Title] then "Name and title both changed" else "Not change"Output
and you can refer to the following code as an sample, create a blank query and put it to advanced editor in power query.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTIwMNAzMACxHJOSgWREZRVI1FAPiIwMjAyUYnWilYzQFaYgVBqhqDSGqzRCN9IYqtAQrNAEi8LwClQjISpN4SqN0Y0EKjQCKTQCKzTDq9AYqjAWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Row = _t, #"Document number" = _t, Title = _t, Name = _t, #"Date of change" = _t]), #"Changed Type" = Table.TransformColumnTypes(Source,{{"Row", Int64.Type}, {"Document number", type number}, {"Title", type text}, {"Name", type text}, {"Date of change", type date}}), #"Grouped Rows" = Table.Group(#"Changed Type", {"Document number"}, {{"Table", each Table.AddIndexColumn(_,"Index",1,1), type table}}), #"Expanded Table" = Table.ExpandTableColumn(#"Grouped Rows", "Table", {"Row", "Title", "Name", "Date of change", "Index"}, {"Row", "Title", "Name", "Date of change", "Index"}), #"Added Custom" = Table.AddColumn(#"Expanded Table", "Custom", each Table.SelectRows(#"Expanded Table",(x)=>x[Document number]=[Document number] and x[Index]=1)), #"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each if [Index]=1 then null else if List.Min([Custom][Title])<>[Title] then "Title Changed" else if List.Min([Custom][Name])<>[Name] then "Name Changed" else if List.Min([Custom][Name])<>[Name] and List.Min([Custom][Title])<>[Title] then "Name and title both changed" else "Not change") /*if [Index]=1 then null else if[Custom][Title]<>[Title] then "Title Changed" else if [Custom][Name]<>[Name] then "Name Changed" else if [Custom][Name]<>[Name] and [Custom][Title]<>[Title] then "Name and title both changed" else "Not change")))*/ in #"Added Custom1"Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
1.You can create a index column grouped by Document number field first, You can refer to the following link.
https://radacad.com/create-row-number-for-each-group-in-power-bi-using-power-query
2.Based on the fiest step, then create a custom column(the index column is created in the first step)
Table.SelectRows(#"Expanded Table",(x)=>x[Document number]=[Document number] and x[Index]=1)
3.Based on the first step, then create a custom column
if [Index]=1 then null else if List.Min([Custom][Title])<>[Title] then "Title Changed" else if List.Min([Custom][Name])<>[Name] then "Name Changed" else if List.Min([Custom][Name])<>[Name] and List.Min([Custom][Title])<>[Title] then "Name and title both changed" else "Not change"
Output
and you can refer to the following code as an sample, create a blank query and put it to advanced editor in power query.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlTSUTIwMNAzMACxHJOSgWREZRVI1FAPiIwMjAyUYnWilYzQFaYgVBqhqDSGqzRCN9IYqtAQrNAEi8LwClQjISpN4SqN0Y0EKjQCKTQCKzTDq9AYqjAWAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Row = _t, #"Document number" = _t, Title = _t, Name = _t, #"Date of change" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Row", Int64.Type}, {"Document number", type number}, {"Title", type text}, {"Name", type text}, {"Date of change", type date}}),
#"Grouped Rows" = Table.Group(#"Changed Type", {"Document number"}, {{"Table", each Table.AddIndexColumn(_,"Index",1,1), type table}}),
#"Expanded Table" = Table.ExpandTableColumn(#"Grouped Rows", "Table", {"Row", "Title", "Name", "Date of change", "Index"}, {"Row", "Title", "Name", "Date of change", "Index"}),
#"Added Custom" = Table.AddColumn(#"Expanded Table", "Custom", each Table.SelectRows(#"Expanded Table",(x)=>x[Document number]=[Document number] and x[Index]=1)),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "Custom.1", each if [Index]=1 then null else if List.Min([Custom][Title])<>[Title] then "Title Changed" else if List.Min([Custom][Name])<>[Name] then "Name Changed" else if List.Min([Custom][Name])<>[Name] and List.Min([Custom][Title])<>[Title] then "Name and title both changed" else "Not change")
/*if [Index]=1 then null else if[Custom][Title]<>[Title] then "Title Changed" else if [Custom][Name]<>[Name] then "Name Changed" else if [Custom][Name]<>[Name] and [Custom][Title]<>[Title] then "Name and title both changed" else "Not change")))*/
in
#"Added Custom1"
Best Regards!
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.