我正在黑斑羚中创建日期趋势表,该表将在Micro策略中用于报告。 我应该使用什么日期函数从所选日期创建当前年份和上一年的日期趋势。 我需要在每个月的第一个工作日将数据加载到趋势表中并添加值。
我使用了工会并为当年和去年拉出日期,但这非常耗资源。
Expected Output
+------------+------------------+-------------+-----------+
selected_date| trend | trend value | sort_order|
+------------+------------------+-------------+-----------+
20190331 | selected mnth | 201903 | 1 |
+------------+------------------+-------------+-----------+
20190331 | selected mnth -1 | 201902 | 2 |
+------------+------------------+-------------+-----------+
20190331 | selected mnth -2 | 201901 | 3 |
+------------+------------------+-------------+-----------+
20190331 | selected mnth -3 | 201812 | 4 |
+------------+------------------+-------------+-----------+
20190331 | selected mnth -4 | 201811 | 5 |
+------------+------------------+-------------+-----------+
20190331 | selected mnth -5 | 201810 | 6 |
+------------+------------------+-------------+-----------+
20190331 | selected mnth -6 | 201809 | 7 |
+------------+------------------+-------------+-----------+
20190331 | selected mnth -7 | 201808 | 8 |
+------------+------------------+-------------+-----------+
20190331 | selected mnth -8 | 201807 | 9 |
+------------+------------------+-------------+-----------+
20190331 | selected mnth -9 | 201806 |10 |
+------------+------------------+-------------+-----------+
20190331 | selected mnth -10| 201805 |11 |
+------------+------------------+-------------+-----------+
20190331 | selected mnth -11| 201804 |12 |
+------------+------------------+-------------+-----------+
20190331 | selected mnth -12| 201803 |13 |
+------------+------------------+-------------+-----------+
20190331 | selected mnth -13| 201802 |14 |
+------------+------------------+-------------+-----------+
20190331 | prev year end | 201812 |1 |
+------------+------------------+-------------+-----------+
20190331 | last 4 Months | 201903 |2 |
+------------+------------------+-------------+-----------+
20190331 | last 4 Months | 201902 |3 |
+------------+------------------+-------------+-----------+
20190331 | last 4 Months | 201901 |4 |
+------------+------------------+-------------+-----------+
20190331 | last 4 Months | 201812 |5 |
+------------+------------------+-------------+-----------+
类似地,将为每个月添加日期作为选定日期。