Hi @dratan99,
See if this is helpful. Just copy this M code into a new blank query.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("lY9LDsMgDESvUrEmksdfyFUi7n+NQFClkmbRWiyYJ3gaH0cC2FNO2MAbE9OL6k5lIaBdrRN9k36nTB6sJtHDOC0Pl/D95/V6IfbgYhUyM19ldi+GlQC70ZcMFC6llLrIftnyEtiHbJbTWoqy1ZkQ4ujzR0l69gZXuHvMJBo8JrV2Ag==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [EmpID = _t, StTime = _t, EnTime = _t, InsDate = _t, ArTime = _t, CorValue = _t, RecValue = _t]),
ChType = Table.TransformColumnTypes(Source,{{"EmpID", Int64.Type}, {"StTime", type datetime}, {"EnTime", type datetime}, {"InsDate", type date}, {"ArTime", type number}, {"CorValue", type number}, {"RecValue", type number}}),
RemoveColumns = Table.RemoveColumns(ChType,{"ArTime", "CorValue", "RecValue"}),
GroupRows = Table.Group(RemoveColumns, {"EmpID", "StTime"}, {{"AllRows", each _, type table [EmpID=nullable number, StTime=nullable datetime, EnTime=nullable datetime, InsDate=nullable date, Date=date]}}),
AddIndex = Table.AddColumn(GroupRows, "Custom", each Table.Sort(Table.AddIndexColumn([AllRows], "Index", 1, 1),{{"InsDate", Order.Ascending}})),
ExpandCustom = Table.ExpandTableColumn(AddIndex, "Custom", {"EnTime", "InsDate", "Index"}, {"EnTime", "InsDate", "Index"}),
Add_ArrTime = Table.AddColumn(ExpandCustom, "Arrival Time", each if [Index] =1 then Number.From( [EnTime] - [StTime]) else null),
Add_CorTime = Table.AddColumn(Add_ArrTime, "Corrected Value", each if [Index]>1 then Number.From( List.LastN([AllRows][EnTime], 1){0} -List.FirstN([AllRows][StTime], 1){0} ) else null),
Add_RecTime = Table.AddColumn(Add_CorTime, "Recovered Value", each if [Index]>1 then Number.From( List.FirstN([AllRows][EnTime], 1){0} - List.LastN([AllRows][EnTime], 1){0} ) else null),
CleanUpColumns = Table.RemoveColumns(Add_RecTime,{"AllRows", "Index"})
in
CleanUpColumns
.
A simple measure like below should do it.
Total Recoverd =
SUM( TableName[Recovered Value] )
I hope this is helpful.