目标: 自己选择统计维度进行数据的汇总统计
数据集参数实现动态列
1、单维度切换
1.1、数据库查询
SELECT
${统计维度} "统计维度",
count(1) "人员总数"
FROM 人员花名册
group by ${统计维度}
1.2、内容配置
$统计维度
下拉框设置
ARRAY("年龄段","学历","岗位职能","岗位类别")
1.3、效果
2、固定维度顺序切换
2.1、数据库查询
SELECT
${INDEXOFARRAY(SPLIT(统计维度,","),1)} "第一维度",
${INDEXOFARRAY(SPLIT(统计维度,","),2)} "第二维度",
count(1) "人员总数"
FROM 人员花名册
group by ${统计维度}
2.2、内容配置
# 两个单元格中的公式如下:
INDEXOFARRAY(SPLIT($统计维度,","),1)
INDEXOFARRAY(SPLIT($统计维度,","),2)
下拉列表设置
ARRAY("年龄段","学历","岗位职能","岗位类别")
2.3、效果
3、非固定数量的统计维度
3.1、数据库查询
SELECT
${if(len(INDEXOFARRAY(SPLIT(统计维度,","),1))==0,"",INDEXOFARRAY(SPLIT(统计维度,","),1)+" 第一维度,")}
${if(len(INDEXOFARRAY(SPLIT(统计维度,","),2))==0,"",INDEXOFARRAY(SPLIT(统计维度,","),2)+" 第二维度,")}
${if(len(INDEXOFARRAY(SPLIT(统计维度,","),3))==0,"",INDEXOFARRAY(SPLIT(统计维度,","),3)+" 第三维度,")}
${if(len(INDEXOFARRAY(SPLIT(统计维度,","),4))==0,"",INDEXOFARRAY(SPLIT(统计维度,","),4)+" 第四维度,")}
count(1) "人员总数"
FROM 人员花名册
${if(len(统计维度)==0,"","group by "+统计维度)}
2.2、内容配置
# 几个单元格中的公式如下:
INDEXOFARRAY(SPLIT($统计维度,","),1)
INDEXOFARRAY(SPLIT($统计维度,","),2)
INDEXOFARRAY(SPLIT($统计维度,","),3)
INDEXOFARRAY(SPLIT($统计维度,","),4)
给单元格增加一个条件属性
len(INDEXOFARRAY(SPLIT($统计维度,","),1)) = 0
len(INDEXOFARRAY(SPLIT($统计维度,","),2)) = 0
len(INDEXOFARRAY(SPLIT($统计维度,","),3)) = 0
len(INDEXOFARRAY(SPLIT($统计维度,","),4)) = 0
下拉列表设置
ARRAY("年龄段","学历","岗位职能","岗位类别")