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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
alya1
Advocate II
Advocate II

How to keep the earliest upload time per day (multiple rows per day)

Hello, 

 

I have a very long table with data from past 5 years (almost) everyday on our list of customers. 

Uploaded Customer ID
1/1/2000 9:00   111
1/1/2000 9:00   222
1/1/2000 9:00   333
1/1/2000 10:03   111
1/1/2000 10:03   222
1/1/2000 10:03   333
1/1/2000 12:24   111
1/1/2000 12:24   222
1/1/2000 12:24   333
1/2/2000 8:00   222
1/2/2000 8:00   333
1/2/2000 8:00   444

etc.

How can I just keep the earliest upload time for each day (only 3 rows of 1/1/2000 9:00 and 3 rows of 1/2/2000 8:00 in the example table) and delete the other duplicate columns?

 

Thank you!

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

This M code works

let
    Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Uploaded", type datetime}, {"Customer ID", Int64.Type}}),
    #"Inserted Date" = Table.AddColumn(#"Changed Type", "Date", each DateTime.Date([Uploaded]), type date),
    #"Grouped Rows" = Table.Group(#"Inserted Date", {"Date"}, {{"Count", each Table.AddRankColumn(_,"Index","Uploaded")}}),
    #"Expanded Count" = Table.ExpandTableColumn(#"Grouped Rows", "Count", {"Uploaded", "Customer ID", "Index"}, {"Uploaded", "Customer ID", "Index"}),
    #"Filtered Rows" = Table.SelectRows(#"Expanded Count", each ([Index] = 1)),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Index"})
in
    #"Removed Columns"

Hope this helps.

Ashish_Mathur_0-1709175528153.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

This M code works

let
    Source = Excel.CurrentWorkbook(){[Name="Data"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Uploaded", type datetime}, {"Customer ID", Int64.Type}}),
    #"Inserted Date" = Table.AddColumn(#"Changed Type", "Date", each DateTime.Date([Uploaded]), type date),
    #"Grouped Rows" = Table.Group(#"Inserted Date", {"Date"}, {{"Count", each Table.AddRankColumn(_,"Index","Uploaded")}}),
    #"Expanded Count" = Table.ExpandTableColumn(#"Grouped Rows", "Count", {"Uploaded", "Customer ID", "Index"}, {"Uploaded", "Customer ID", "Index"}),
    #"Filtered Rows" = Table.SelectRows(#"Expanded Count", each ([Index] = 1)),
    #"Removed Columns" = Table.RemoveColumns(#"Filtered Rows",{"Index"})
in
    #"Removed Columns"

Hope this helps.

Ashish_Mathur_0-1709175528153.png

 


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Thank you Ashish! Would you mind sharing your .pbix file please? I am running into a few errors 

You are welcome.  PBI file attached.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
ryan_mayu
Super User
Super User

@alya1 

here is a workaround for you





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Hi Ryan, thank you for your response! This works for this sample table but my actual data is from past 5 years with uploads (almost) everyday. It would be time consuming to create a date table with each date and first uploaded time. May I ask for any other ideas? 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

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