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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
Vara
Frequent Visitor

Help to filter records with minimum duration for each date / Excel PowerQuery

Hi all,

 

could you please help to filter rows with minimum duration for each date ?.

 

Data set: 

 

Date modified        SelectedDate               Duration
19/06/2017 01:03   01/07/2017 00:00       273.6862792
22/06/2017 09:53   01/07/2017 00:00       192.8536673
22/06/2017 09:53   01/07/2017 00:00       192.8536673
29/06/2017 11:42   01/07/2017 00:00       23.03526859*
19/06/2017 01:03   01/07/2017 00:00      273.6862792
29/06/2017 11:42 02/07/2017 00:00      47.03526859*
22/06/2017 09:53 02/07/2017 00:00 216.8536673
19/06/2017 01:03 02/07/2017 00:00 297.6862792
19/06/2017 01:03 02/07/2017 00:00 297.6862792
22/06/2017 09:53 02/07/2017 00:00 216.8536673
02/07/2017 20:24 04/07/2017 00:00 14.34479694
03/07/2017 09:20 04/07/2017 00:00 1.414989898*
02/07/2017 20:24 04/07/2017 00:00 14.34479694
29/06/2017 11:42 04/07/2017 00:00 95.03526859
02/07/2017 20:24 05/07/2017 00:00 38.34479694
03/07/2017 09:20 05/07/2017 00:00 25.4149899*
02/07/2017 20:24 05/07/2017 00:00 38.34479694
29/06/2017 11:42 05/07/2017 00:00 119.0352686

 

Expecting the values marked as * for each Selected Date .

 

Thanks in advance.

1 ACCEPTED SOLUTION
Vera_33
Resident Rockstar
Resident Rockstar

Hi @Vara 

 

You want to filter the table down to min duration for each selected date only? Here is one way, paste in Advanced Editor to see the Groupby and join

Vera_33_0-1622644191717.png

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("lZBLCgMhEETv4npQ+2+fRbz/NUKSCXQvDCOuGh9Vj5qzgLeuDTtYuUqH1u13oFHVoWiOZV2zIO5IcKxDSNXolNy3U+0kqEP8Qx54JhIDyZYzs2ckETR5wjYT3VL7c/J5e/rsHPfkSszm6vwlaUtWBvbxfoeZec9IuuQ9c6aEg8Y/z0ii3KKnkVkzkgB+e2pZ6wU=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Date modified" = _t, SelectedDate = _t, Duration = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date modified", type date}, {"SelectedDate", type date}, {"Duration", type number}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"SelectedDate"}, {{"MinDuration", each List.Min([Duration]), type nullable number}}),
    #"Merged Queries" = Table.NestedJoin(#"Grouped Rows", {"SelectedDate", "MinDuration"}, #"Changed Type", {"SelectedDate", "Duration"}, "Grouped Rows", JoinKind.LeftOuter),
    #"Expanded Grouped Rows" = Table.ExpandTableColumn(#"Merged Queries", "Grouped Rows", {"Date modified"}, {"Date modified"})
in
    #"Expanded Grouped Rows"

 

View solution in original post

2 REPLIES 2
Vara
Frequent Visitor

Thanks it worked.

Vera_33
Resident Rockstar
Resident Rockstar

Hi @Vara 

 

You want to filter the table down to min duration for each selected date only? Here is one way, paste in Advanced Editor to see the Groupby and join

Vera_33_0-1622644191717.png

 

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("lZBLCgMhEETv4npQ+2+fRbz/NUKSCXQvDCOuGh9Vj5qzgLeuDTtYuUqH1u13oFHVoWiOZV2zIO5IcKxDSNXolNy3U+0kqEP8Qx54JhIDyZYzs2ckETR5wjYT3VL7c/J5e/rsHPfkSszm6vwlaUtWBvbxfoeZec9IuuQ9c6aEg8Y/z0ii3KKnkVkzkgB+e2pZ6wU=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Date modified" = _t, SelectedDate = _t, Duration = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date modified", type date}, {"SelectedDate", type date}, {"Duration", type number}}),
    #"Grouped Rows" = Table.Group(#"Changed Type", {"SelectedDate"}, {{"MinDuration", each List.Min([Duration]), type nullable number}}),
    #"Merged Queries" = Table.NestedJoin(#"Grouped Rows", {"SelectedDate", "MinDuration"}, #"Changed Type", {"SelectedDate", "Duration"}, "Grouped Rows", JoinKind.LeftOuter),
    #"Expanded Grouped Rows" = Table.ExpandTableColumn(#"Merged Queries", "Grouped Rows", {"Date modified"}, {"Date modified"})
in
    #"Expanded Grouped Rows"

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors