Forum Discussion
Removing Duplicate Line Items/Documents Based on Most Recent Version
I've been wrestling with 'Transform', 'Group By' and 'Advanced Editor' in an attempt to try to remove duplicate CQTitles from the list and the visual in Power BI. Any assistance is appreciated.
11 Replies
- smpa01
Community Champion
Anonymous please try this
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUTLUN9Q3MjAyUIrVgQgYoQsYwwViAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [title = _t, Column1 = _t]), #"Renamed Columns" = Table.RenameColumns(Source,{{"Column1", "date"}}), #"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns",{{"title", type text}, {"date", type date}}), #"Grouped Rows" = Table.Group(#"Changed Type", {"title"}, {{"ad", each _, type table [title=nullable text, Column1=nullable date]}}), #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each let x=[ad], y = Table.SelectRows(x, each ([date] = List.Max(x[date]))) in y), #"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"Custom"}), #"Expanded Custom" = Table.ExpandTableColumn(#"Removed Other Columns", "Custom", {"title", "date"}, {"title", "date"}) in #"Expanded Custom"- AnonymousNot applicable
Am I to simply cut and paste this into the 'Advanced Editor' while the 'DteofCQ' is highlighted? Please clarify how this is to be applied.
let Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WSlTSUTLUN9Q3MjAyUIrVgQgYoQsYwwViAQ==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [title = _t, Column1 = _t]), #"Renamed Columns" = Table.RenameColumns(Source,{{"Column1", "date"}}), #"Changed Type" = Table.TransformColumnTypes(#"Renamed Columns",{{"title", type text}, {"date", type date}}), #"Grouped Rows" = Table.Group(#"Changed Type", {"title"}, {{"ad", each _, type table [title=nullable text, Column1=nullable date]}}), #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each let x=[ad], y = Table.SelectRows(x, each ([date] = List.Max(x[date]))) in y), #"Removed Other Columns" = Table.SelectColumns(#"Added Custom",{"Custom"}), #"Expanded Custom" = Table.ExpandTableColumn(#"Removed Other Columns", "Custom", {"title", "date"}, {"title", "date"}) in #"Expanded Custom"
- smpa01
Community Champion
Anonymousno, I wanted you to write a query to show you how can you adapt my query to your scenario. If you want the query to speak exactly to your scenario, please provide sample data here in a format that is copy paste able.
- v-deddai1-msft
Community Support
Hi Anonymous ,
You can use group by in query editor:
If you need accurate help, would you please show us sample data and expected output (pbix file) by onedrive for business.
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best Regards,
Dedmon Dai
- AnonymousNot applicable
How would your suggestion be configured to only return the most recent version of all CQTitles; eliminating ALL duplicates of CQTitles except the most recent?
- v-deddai1-msft
Community Support
Hi Anonymous ,
Are you trying to eliminating all duplicates of CQTitles except the most recent in data table or in table visual?
For the former, you can try group by as mentioned by me above.
For the latter, you can create a visual level filter like:
measure = IF(CALCULATE(MAX('Table'[Date]),allexcept('Table','Table'[CQTitle])) = MAX('Table'[Date]),1,0)And set it to 1.
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Best Regards,
Dedmon Dai
- AnonymousNot applicable
Thank you.
The effort returned the following; in the visual you can see the same CQTitle for the individual in 2018 and 2019.
Where such duplicates exist only the MOST Recent should show in the visual, not both.A refresh then changed the visual table to the following. The duplicates remain, but the dates default to the year '1900'.
Please advise.
- v-deddai1-msft
Community Support
Hi Anonymous ,
Is the date column in your screenshot is the same column as DteofCQ column? It's better that you can show us sample pbix by onedrive for business. So we can help you well.
Best Regards,
Dedmon Dai.