1、导入数据
- 可以参考导入Excel数据,直接导入数据
- 也可以在数据库建表,Navicat直接导入数据
以下是数据库建表操作
-- 创建表
create table test11 (
orderTime date NULL, -- 下单时间
quantity int NULL -- 数量
);
导入数据
2、SQL判断统计维度
-- sqlserver
SELECT
${switch(维度,"日","day(orderTime)","周","DATENAME(WEEK, orderTime)","月","month(orderTime)")} '时间'
,sum(quantity) '总销售数量'
FROM test11
where year(orderTime) = 2021
group by ${switch(维度,"日","day(orderTime)","周","DATENAME(WEEK, orderTime)","月","month(orderTime)")}
SELECT
${switch(维度,"日","day(orderTime)","周","concat('W',week(orderTime))","月","month(orderTime)")} '时间'
,sum(quantity) '总销售数量'
FROM test11
group by ${switch(维度,"日","day(orderTime)","周","concat('W',week(orderTime))","月","month(orderTime)")}
预览数据,维度为“月”时
3、构建折线图
3.1、拉取折线图
3.2、增加一个模板参数
3.3、新增报表块
判断当前单元格的值是否等于创建的模板参数维度
每个都添加两个超级链接,类型为当前决策报表对象,想同时控制多个图表,就需要多增加几个超级链接
传递参数“维度”,值就是当前单元格的值,可以用公式$$$表示