@biterbit
Yes the Formula provided will achieve what you want.
For clarity as well - the formula I provide does not "change" anything. It returns a Table with the combined items as you have in your list. Since I would not use a collection for this, I left the option to you as to how you use it.
For example, if you set that formula to the Items property of a Gallery, you would get the records combined as you have requested. Or if you set this to a variable, you will have a snapshot of the table as requested.
However, now that you have provided sample data, there will be one issue with it...That is you have a StartTime in the second records as well. This will cause an issue if the column is there and is blank as it will override the first. This was not clear in the original post...so thank you for the sample data. So, we'll need to adjust a little.
There are a couple of ways to go about it, but IF you are really trying to put those two records together and the EndTime and StartTime are what are you are really focused on, then the following formula will provide the information needed:
ForAll(Sequence(CountRows(yourTable), 1, 2),
Patch(Last(FirstN(yourTable, Value)), {EndTime: Last(FirstN(yourTable, Value+1)).EndTime})
)
Based on the sample data you have provided, these are the results you will get in the resultant table from the above formula.
To be specific, it will output a table as follows:
[
{SourceID: 12, DayNo: 1, StartTime: 9, EndTime: 12},
{SourceID: 48, DayNo: 3, StartTime: 14, EndTime: 16}
]