我在 BigQuery 中有一个表格,它跟踪从 2019 年 6 月开始的每个季度的支出金额。我需要计算年同比和月同比百分比变化。我已经提到了他们两个的适当公式。对 YoY 和 MoM 跨行执行计算对我来说有点棘手。有人可以帮忙吗?
桌子:
period report_date spend_dollar
30-jun-19 2019-06-30 5022087
30-sept-19 2019-09-30 4958617
31-dec-19 2019-09-30 5038630
31-mar-20 2020-03-31 5156327
30-jun-20 2020-06-30 5344183
30-sept-20 2020-09-30 5562796
31-dec-20 2020-12-31 5696796
31-mar-21. 2021-03-31 5749467
30-jun-20. 2021-06-30 5680087
同比预期产出:
period report_date spend_dollar. year_over_year
30-jun-19 2019-06-30 5022087 -
30-sept-19 2019-09-30 4958617 -
31-dec-19 2019-09-30 5038630 -
31-mar-20 2020-03-31 5156327 -
30-jun-20 2020-06-30 5344183 6.4
30-sept-20 2020-09-30 5562796 12.18
31-dec-20 2020-12-31 5696796 13.1
31-mar-21. 2021-03-31 5749467 11.5
30-jun-20. 2021-06-30 5680087 6.3
YoY formula example formula:
((spend_dollar value for date 2021-06-30/spend_dollar for date 2020--06-30)-1)*100,
((spend_dollar value for date 2020-03-30/spend_dollar for date 2020--03-30)-1)*100
..
月度预期产出:
period report_date spend_dollar. month_over_month
30-jun-19 2019-06-30 5022087 -
30-sept-19 2019-09-30 4958617. -1.2
31-dec-19 2019-09-30 5038630. 1.6
31-mar-20 2020-03-31 5156327 2.3
30-jun-20 2020-06-30 5344183. 6.4
30-sept-20 2020-09-30 5562796. 4.1
31-dec-20 2020-12-31 5696796 2.4
31-mar-21. 2021-03-31 5749467 0.092
30-jun-20. 2021-06-30 5680087 -1.2
Month-over-Month example formula:
((spend_dollar value for date 2021-06-30/spend_dollar for date 2021--03-30)-1)*100 ,
((spend_dollar value for date 2021-03-30/spend_dollar for date 2020--12-31)-1)*100
..