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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
aneeshvarghese
Frequent Visitor

How to remove duplicate from the record by group by id and select min(date)

Hi Guys,

I want to filter my table by grouping same ticket number and selecting only records with same ticketnumber which has the ealiest allocated on date.

I have been putting my head on this for a while now.  if anybody can help it would be osem.



Attaching excel file for reference.  Also image shows the tickets which are duplicated with differeent allocated date. I want to select one from the duplicate cases based on the earliest Allocated date. hope it helps to understand


Capture.PNG

  this is how it would look like after.

 Capture2.PNG

 

For excel file Click here

 

Thanks in advance

1 ACCEPTED SOLUTION
Zubair_Muhammad
Community Champion
Community Champion

@aneeshvarghese

 

You can use this

Please see attached excel file's Query Editor

 

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Ticketnumber", Int64.Type}, {"Title", type text}, {"Created On", type datetime}, {"Allocated on", type datetime}, {"Resolved on", type datetime}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Ticketnumber"}, {{"Earliest Allocation Date", each List.Min([Allocated on]), type datetime}, {"All Rows", each _, type table}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each let mydate = [Earliest Allocation Date] in
Table.SelectRows([All Rows],each [Allocated on] = mydate)),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Title", "Created On", "Allocated on", "Resolved on"}, {"Title", "Created On", "Allocated on", "Resolved on"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded Custom",{"Earliest Allocation Date", "All Rows"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Removed Columns",{{"Created On", type datetime}, {"Allocated on", type datetime}, {"Resolved on", type datetime}})
in
    #"Changed Type1"

 

 

 

View solution in original post

2 REPLIES 2
v-danhe-msft
Microsoft Employee
Microsoft Employee

Hi @aneeshvarghese,

Could you please tell me if your problem has been solved? If it is, could you please mark the helpful replies as Answered?

 

Regards,

Daniel He

Community Support Team _ Daniel He
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Zubair_Muhammad
Community Champion
Community Champion

@aneeshvarghese

 

You can use this

Please see attached excel file's Query Editor

 

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Ticketnumber", Int64.Type}, {"Title", type text}, {"Created On", type datetime}, {"Allocated on", type datetime}, {"Resolved on", type datetime}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"Ticketnumber"}, {{"Earliest Allocation Date", each List.Min([Allocated on]), type datetime}, {"All Rows", each _, type table}}),
    #"Added Custom" = Table.AddColumn(#"Grouped Rows", "Custom", each let mydate = [Earliest Allocation Date] in
Table.SelectRows([All Rows],each [Allocated on] = mydate)),
    #"Expanded Custom" = Table.ExpandTableColumn(#"Added Custom", "Custom", {"Title", "Created On", "Allocated on", "Resolved on"}, {"Title", "Created On", "Allocated on", "Resolved on"}),
    #"Removed Columns" = Table.RemoveColumns(#"Expanded Custom",{"Earliest Allocation Date", "All Rows"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Removed Columns",{{"Created On", type datetime}, {"Allocated on", type datetime}, {"Resolved on", type datetime}})
in
    #"Changed Type1"

 

 

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors