Can anyone help me to calculate usage/month based on the data I have below. The dataset is on serial_number level with the MaxHours for that month. The MaxHours should always increase with the months but we have few entries where MaxHours are lesser than the last month trend so we need to fix these by replacing the previous month values (as listed on Max-Hours Updated). Then there's another column "Next Max Hours" which shows the upcoming next hours for each month and serial number. The "Next-Current" column will simple calculate the difference between "Next Max Hours" and "Max-Hours Updated" but for the rows where we put the last month Max-Hours value in "Max-Hours Updated" it should also pick the last "Next-Current" value in order to eliminate the 0s. Then there's another column "diff_month" which just calculates the difference between Current row YearMonth and previous Month row in Months. And then there's last column which just divides the "Next-Current" with "diff_month" to calculate the usage/month for each row. You can see the required changes in higlighted cells.