Q:

How can I get the min and max date from a table?

I have one table as below. I want to have another table in power bi which can tell me on a particular date what is the Min(StartTime) and Max(endTime).
LogTime   Job_Name   StartTime       endTime
9/18/2018   Job1    9/18/2018 10:27 9/18/2018 10:28
9/18/2018   Job2    9/18/2018 9:47  9/18/2018 9:51
9/18/2018   Job3    9/18/2018 9:41  9/18/2018 9:50
9/18/2018   Job4    9/18/2018 9:46  9/18/2018 9:48
9/17/2018   Job5    9/17/2018 11:23 9/17/2018 11:25
9/17/2018   Job6    9/17/2018 11:17 9/17/2018 11:24
9/16/2018   Job7    9/16/2018 17:20 9/16/2018 17:23
9/16/2018   Job8    9/16/2018 17:18 9/16/2018 17:21
9/16/2018   Job9    9/16/2018 17:17 9/16/2018 17:21
9/14/2018   Job10   9/14/2018 17:19 9/14/2018 17:21
9/14/2018   Job11   9/14/2018 17:19 9/14/2018 17:20
9/14/2018   Job12   9/14/2018 17:17 9/14/2018 17:20
9/14/2018   Job13   9/14/2018 17:16 9/14/2018 17:20

Required Table:
LogTime      StartTime       endTime        endTime-StartTime
9/18/2018   9/18/2018 9:46  9/18/2018 10:28 hh:mm
9/17/2018   9/17/2018 11:17 9/17/2018 11:25 
9/16/2018   9/16/2018 17:17 9/16/2018 17:23 
9/14/2018   9/14/2018 17:16 9/14/2018 17:21 

A:

You can achieve this by using the Power Query Editor. I named the startingpoint (your data) baseTable and used that as the source for the targetTable (your Required Table).

These are the steps:

Use [Group by] (advanced) on the Transform tab. Group by "LogTime". Make two aggregations (minTime and maxTime"). Operation: All Rows.
Add two Custom Columns, extracting the StartTime and the EndTime record. (see the script)
Expand the record in both columns
Create a Custom Column (substract StartTime from EndTime). Change Datatype to Duration
Delete Columns [MinTime] and [MaxTime]

The script looks like this:
let
Source = #"baseTable",
#"Grouped Rows" = Table.Group(Source, {"LogTime"}, {{"minTime", each _, type table}, {"maxTime", each _, type table}}),
#"Added Custom" = Table.AddColumn(#"Grouped Rows", "minStart", each Table.Min([minTime],"StartTime")),
#"Added Custom1" = Table.AddColumn(#"Added Custom", "maxEnd", each Table.Max([maxTime],"endTime")),
#"Expanded minStart" = Table.ExpandRecordColumn(#"Added Custom1", "minStart", {"StartTime"}, {"StartTime"}),
#"Expanded maxEnd" = Table.ExpandRecordColumn(#"Expanded minStart", "maxEnd", {"endTime"}, {"endTime"}),
#"Added Custom2" = Table.AddColumn(#"Expanded maxEnd", "endTime-StartTime", each [endTime]-[StartTime]),
#"Changed Type" = Table.TransformColumnTypes(#"Added Custom2",{{"StartTime", type time}, {"endTime", type time}, {"endTime-StartTime", type duration}}),
#"Removed Columns" = Table.RemoveColumns(#"Changed Type",{"minTime", "maxTime"})
in
#"Removed Columns"

When you copy this script to the Advanced Editor, using a Blank Query for a New Source, you should be able to review the Applied Steps.

