I am trying to calculate the rate the units in an authorization are used per month so I can determine the rate at which all the units on the auth will get used up.
I have tried using the lag function which gives me the difference from the previous month but I don't know how to take it a step further and get the rate at which the auth units are being used.
For example I have
Month Monthly_units Diff_to_prev
9/1 650 NULL
10/1 675 25
11/1 725 50
12/1 775 50
1/1 935 160
Trying to figure out the growth(?) rate? Any help would be much appreciated. I've done a lot of research but haven't found anything other than lag that resembles what I am trying to do.
Here is my code
[external auth no],
total_monthly_units - lag(total_monthly_units) over (partition by [Medicaid No#], [external auth no] order by month) as diff_to_prev