客户经常提出这样的需求,当用户选择某一时间时,图表中显示所选时间之前一年的数据。下面是我的方法,如有不当,请多指教:
数据准备如下所示:
SalesData:
LOAD
Num(ID) as ID,
Date(Date) as Date,
Month,
Num(Year) as Year,
Num(Sales) as Sales
Inline [
ID, Date, Month, Year, Sales
1, 2012-1-1, 2012-1, 2012, 20
2, 2012-1-1, 2012-2, 2012, 21
3, 2012-1-1, 2012-3, 2012, 23
4, 2013-1-1, 2013-1, 2013, 34
5, 2013-2-1, 2013-2, 2013, 35
6, 2013-3-1, 2013-3, 2013, 46
7, 2014-1-1, 2014-1, 2014, 27
8, 2014-2-1, 2014-2, 2014, 30
9, 2014-3-1, 2014-3, 2014, 49
];
新建图表:
将Month作为维度,如图所示: