Using date, I have already created Quarter column in pandas dataframe
df['Quarter'] = pd.DatetimeIndex(df['date']).quarter
Now, i am looking for Quarter aging as a calculated column like below
df['Quarter Aging'] = ????
so that I can compare current quarter and Last quarter sales differences dynamically when years are passing in the sales reporting. Expected output is Click here
For example, If my Current Quarter is 2022-Q4, then my Quarter aging is 0 Likewise,
2022-Q4 = 0
2022-Q3 = -1
2022-Q2 = -2
2022-Q1 = -3
2021-Q4 = -4
2021-Q3 = -5
2021-Q2 = -6
2021-Q1 = -7
. . . . . . . . . .
2018-Q1 = -19