Forum Discussion
Remove duplicates - keep last vs keep first
- 9 years ago
In this scenario, if you want to keep the last records associated with each group column. You can build a calculated table aggregating values with max sort within each group.
I assume you a have a table like below:
Then you can create a calculated table like below:
Table = SUMMARIZE( Table3,Table3[Name], "Last Value", CALCULATE(SUM(Table3[Value]), FILTER(Table3,Table3[Sort]=MAX(Table3[Sort])) ) )
Regards,
Hi! Can you help me add a custom column counting the number of entries? Outcome shall be the same as the SORT column used here. Thank you!
Hi,
Share some data, describe the question and show the expected result.
- hmenco5 years agoFrequent Visitor
I need an additional custom column PQ Editor that COUNTS the number of OrderNumber entries..
Goal is to remove the duplicates and get the latest entry based on RunDate.
I have tried the Table.Buffer but it seems not to be applicable because it slows down the performance/process. I thought of this workaround instead...
- Ashish_Mathur5 years agoSuper User
Hi,
Does this M Query work faster? If not, then let me know. I will share a calculated column formula in DAX with you.
let Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content], #"Changed Type" = Table.TransformColumnTypes(Source,{{"OrderNumber", Int64.Type}, {"RunDate", type date}}), #"Sorted Rows" = Table.Sort(#"Changed Type",{{"OrderNumber", Order.Ascending}, {"RunDate", Order.Ascending}}), Partition = Table.Group(#"Sorted Rows", {"OrderNumber"}, {{"Partition", each Table.AddIndexColumn(_, "Index",1,1), type table}}), #"Expanded Partition" = Table.ExpandTableColumn(Partition, "Partition", {"RunDate", "Index"}, {"RunDate", "Index"}) in #"Expanded Partition"- hmenco5 years agoFrequent Visitor
Hi Ashish_Mathur, thank you but do you have another work around? The M query takes time to process big data.