Home > Database > Mysql Tutorial > QlikView显示所选时间前一年的数据

QlikView显示所选时间前一年的数据

WBOY
Release: 2016-06-07 16:01:30
Original
1171 people have browsed it

客户经常提出这样的需求,当用户选择某一时间时,图表中显示所选时间之前一年的数据。下面是我的方法,如有不当,请多指教: 数据准备如下所示: SalesData:LOADNum(ID) as ID,Date(Date) as Date,Month,Num(Year) as Year,Num(Sales) as SalesInline [ID, D

客户经常提出这样的需求,当用户选择某一时间时,图表中显示所选时间之前一年的数据。下面是我的方法,如有不当,请多指教:

数据准备如下所示:

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
];
Copy after login

新建图表:

\

将Month作为维度,如图所示:

\

在表达式那个tab中新建一个Expression 如下所示:

\

Sales表达式如下:

=Sum({$<
	Date={&#39;>$(=Date(Max(Date)-365))<=$(=Date(Max(Date)))&#39;}
>}Sales)
Copy after login


点击确定,然后新建一个Date列表,如下图所示,假如什么日期都不选,Sales图表默认显示最近一年的数据:

\

假如选择一个时间,Sales图表将会显示所选日期之前一年的数据,如下图所示,由于选择了2014-1-1,Sale图表显示了2014-1-1号之前一年的数据。\

 

总结:上面Sales表达式证明了QlikView中可以实现">=","

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template