let
Source = Excel.CurrentWorkbook(){[Name="Readings"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"ID", type text}, {"Meter Reading", Int64.Type}}),
#"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1),
#"Sorted Rows" = Table.Buffer(Table.Sort(#"Added Index",{{"ID", Order.Ascending}, {"Meter Reading", Order.Ascending}})),
#"Grouped Rows" = Table.Group(#"Sorted Rows", {"ID"}, {{"Count", each Table.AddIndexColumn(_, "Index2", 1,1),type table}}),
#"Expanded Count" = Table.ExpandTableColumn(#"Grouped Rows", "Count", {"Meter Reading", "Index", "Index2"}, {"Meter Reading", "Index", "Index2"}),
#"Changed Type1" = Table.TransformColumnTypes(#"Expanded Count",{{"Meter Reading", Int64.Type}, {"Index", Int64.Type}, {"Index2", Int64.Type}}),
#"Inserted Addition" = Table.AddColumn(#"Changed Type1", "Addition", each [Index2] + 1, type number),
#"Merged Queries" = Table.NestedJoin(#"Inserted Addition",{"ID", "Index2"},#"Inserted Addition",{"ID", "Addition"},"Inserted Addition",JoinKind.LeftOuter),
#"Expanded Inserted Addition" = Table.ExpandTableColumn(#"Merged Queries", "Inserted Addition", {"Meter Reading"}, {"Last Reading"}),
#"Sorted Rows1" = Table.Sort(#"Expanded Inserted Addition",{{"Index", Order.Ascending}}),
#"Removed Other Columns" = Table.SelectColumns(#"Sorted Rows1",{"ID", "Meter Reading", "Last Reading"})
in
#"Removed Other Columns"