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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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"

 

 

 


Regards
Zubair

Please try my custom visuals

View solution in original post

2 REPLIES 2
v-danhe-msft
Employee
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"

 

 

 


Regards
Zubair

Please try my custom visuals

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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