博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
【BIEE】11_根据显示指标展示不同报表
阅读量:5924 次
发布时间:2019-06-19

本文共 6668 字,大约阅读时间需要 22 分钟。

报表开发过程中,我们经常会需要根据所选择的不同指标,展示不同的报表!例如:

显示指标有:金额与合同数,可以根据显示指标选择的内容进行相应报表数据展示

一、环境准备

create table crm_info(crm_name varchar(100) ,crm_no varchar(40) not null primary key ,crm_type varchar(8),crm_lvl varchar(8),crm_status varchar(8),crm_indu varchar(8),crm_sex varchar(8),crm_birthdate Date,crm_dept varchar(8),crm_country varchar(8),crm_email varchar(20));insert into crm_info  values('牧云笙','crm001','uvip','A','01','A','01',to_date('1987-10-02','yyyy-mm-dd'),'A01','CN','crm001@163.com');insert into crm_info  values('苏语凝','crm002','vip','B','01','S','02',to_date('1986-1-2','yyyy-mm-dd'),'A04','USA','crm002@163.com');insert into crm_info  values('南枯月漓','crm003','vip','D','01','D','02',to_date('1973-02-02','yyyy-mm-dd'),'A03','UK','crm003@163.com');insert into crm_info  values('赫兰铁朵','crm004','uvip','B','01','M','01',to_date('1999-12-01','yyyy-mm-dd'),'A02','USA','crm004@163.com');insert into crm_info  values('牧云寒','crm005','vip','D','01','T','02',to_date('1965-01-01','yyyy-mm-dd'),'A01','USA','crm005@163.com');insert into crm_info  values('硕风和叶','crm006','uvip','D','02','U','01',to_date('1996-01-23','yyyy-mm-dd'),'A01','CN','crm006@163.com');insert into crm_info  values('盼兮','crm007','uvip','C','01','B','02',to_date('1998-01-01','yyyy-mm-dd'),'A03','CN','crm007@163.com');insert into crm_info  values('穆如寒江','crm008','vip','D','02','S','01',to_date('1976-12-4','yyyy-mm-dd'),'A02','CN','crm008@163.com');insert into crm_info  values('兰钰儿','crm009','vip','A','01','S','02',to_date('1986-4-6','yyyy-mm-dd'),'A03','UK','crm009@163.com');insert into crm_info  values('牧云陆','crm010','vip','B','01','L','01',to_date('1988-4-5','yyyy-mm-dd'),'A01','CN','crm010@163.com');commit;create table contract_info(contract_no varchar(40) not null primary key,crm_no varchar(40),contract_amt decimal(18,2),start_date varchar(8),end_date varchar(8),register_date varchar(8));INSERT INTO contract_Info values('contract01','crm002','1230000','20170203','20180203','20170203');INSERT INTO contract_Info values('contract02','crm003','200000000','20160209','20170209','20160209');INSERT INTO contract_Info values('contract03','crm004','200000000','20150609','20160609','20150609');INSERT INTO contract_Info values('contract04','crm005','23000000','20170203','20180203','20170203');INSERT INTO contract_Info values('contract05','crm006','1000000','20160506','20170506','20160506');INSERT INTO contract_Info values('contract06','crm007','100000000','20180101','20190101','20180101');INSERT INTO contract_Info values('contract07','crm002','2000000','20170202','20180202','20170202');INSERT INTO contract_Info values('contract08','crm003','200000000','20170405','20180405','20170405');INSERT INTO contract_Info values('contract09','crm004','500000','20110101','20170101','20110101');INSERT INTO contract_Info values('contract10','crm005','633333','20120223','20180223','20120223');INSERT INTO contract_Info values('contract11','crm006','45000000','20160101','20180101','20160101');create table mapping(Type VARCHAR(20),Key varchar(4),Value varchar(100));INSERT INTO mapping VALUES('crm_lvl','vip','vip客户');INSERT INTO mapping VALUES('crm_lvl','uvip','非vip客户');INSERT INTO mapping VALUES('crm_type','A','优秀');INSERT INTO mapping VALUES('crm_type','B','良好');INSERT INTO mapping VALUES('crm_type','C','中等');INSERT INTO mapping VALUES('crm_type','D','一般');INSERT INTO mapping VALUES('crm_status','01','存续客户');INSERT INTO mapping VALUES('crm_status','02','流失客户');INSERT INTO mapping VALUES('crm_indu','A','农、牧、林、渔业');INSERT INTO mapping VALUES('crm_indu','B','采矿和采石');INSERT INTO mapping VALUES('crm_indu','C','制造业');INSERT INTO mapping VALUES('crm_indu','D','电、煤气、蒸汽和空调供应');INSERT INTO mapping VALUES('crm_indu','E','供水;污水处理、废物管理和补救');INSERT INTO mapping VALUES('crm_indu','F','建筑业');INSERT INTO mapping VALUES('crm_indu','G','批发和零售业;汽车和摩托车修理');INSERT INTO mapping VALUES('crm_indu','H','运输与存储');INSERT INTO mapping VALUES('crm_indu','I','食宿服务');INSERT INTO mapping VALUES('crm_indu','J','信息和通信');INSERT INTO mapping VALUES('crm_indu','K','金融和保险');INSERT INTO mapping VALUES('crm_indu','L','房地产');INSERT INTO mapping VALUES('crm_indu','M','专业、科学和技术');INSERT INTO mapping VALUES('crm_indu','N','行政和辅助');INSERT INTO mapping VALUES('crm_indu','O','公共管理与国防;强制性社会保障');INSERT INTO mapping VALUES('crm_indu','P','教育');INSERT INTO mapping VALUES('crm_indu','Q','人体健康和社会工作');INSERT INTO mapping VALUES('crm_indu','R','艺术、娱乐和文娱');INSERT INTO mapping VALUES('crm_indu','S','其他服务');INSERT INTO mapping VALUES('crm_indu','T','家庭作为雇主的;家庭自用、未加区分的物品生产和服务');INSERT INTO mapping VALUES('crm_indu','U','国际组织和机构');INSERT INTO mapping VALUES('crm_sex','01','男');INSERT INTO mapping VALUES('crm_sex','02','女');INSERT INTO mapping VALUES('crm_dept','A01','财务部');INSERT INTO mapping VALUES('crm_dept','A02','人事部');INSERT INTO mapping VALUES('crm_dept','A03','采购部');INSERT INTO mapping VALUES('crm_dept','A04','市场部');INSERT INTO mapping VALUES('crm_country','CN','中国');INSERT INTO mapping VALUES('crm_country','USA','美国');INSERT INTO mapping VALUES('crm_country','UK','英国');commit;------建立维度视图CREATE OR REPLACE VIEW V_DIM_CRM_LVLAS SELECT KEY,VALUE FROM mapping WHERE Type='crm_lvl';CREATE OR REPLACE VIEW V_DIM_CRM_TYPEAS SELECT KEY,VALUE FROM mapping WHERE Type='crm_type';CREATE OR REPLACE VIEW V_DIM_CRM_STATUSAS SELECT KEY,VALUE FROM mapping WHERE Type='crm_status';CREATE OR REPLACE VIEW V_DIM_CRM_INDUAS SELECT KEY,VALUE FROM mapping WHERE Type='crm_indu';CREATE OR REPLACE VIEW V_DIM_CRM_SEXAS SELECT KEY,VALUE FROM mapping WHERE Type='crm_sex';CREATE OR REPLACE VIEW V_DIM_CRM_DEPTAS SELECT KEY,VALUE FROM mapping WHERE Type='crm_dept';CREATE OR REPLACE VIEW V_DIM_CRM_COUNTRYAS SELECT KEY,VALUE FROM mapping WHERE Type='crm_country';-----建立合同客户关系视图CREATE OR REPLACE VIEW CRM_CONTRACT_RELATIONASSELECT A.CONTRACT_NO,A.CONTRACT_AMT,A.START_DATE,A.END_DATE,A.REGISTER_DATE,B.* FROM contract_Info A INNER JOIN CRM_INFO B ON A.CRM_NO=B.CRM_NO

根据上述脚本建表后,可得到如下数据:

CRM_CONTRACT_RELATION

V_DIM_CRM_COUNTRY

将上述两个视图导入到资料库,然后关联,接着设计分析

二、仪表盘提示设计

使用变量VAR接受值,然后传值给分析,在分析中通过@{VAR}进行引用

三、分析设计

①国家:

"V_DIM_CRM_COUNTRY"."VALUE"

②vip金额:

ifnull(CASE WHEN '@{VAR}{金额}'='金额' AND "CRM_CONTRACT_RELATION"."CRM_TYPE"='vip' THEN "CRM_CONTRACT_RELATION"."合同金额" WHEN  '@{VAR}'='合同数' AND  "CRM_CONTRACT_RELATION"."CRM_TYPE"='vip'  THEN  "CRM_CONTRACT_RELATION"."CNT"  ELSE NULL END,0)

③非vip金额:

ifnull(CASE WHEN '@{VAR}{金额}'='金额' AND "CRM_CONTRACT_RELATION"."CRM_TYPE"='uvip' THEN "CRM_CONTRACT_RELATION"."合同金额" WHEN  '@{VAR}'='合同数' AND  "CRM_CONTRACT_RELATION"."CRM_TYPE"='uvip'  THEN  "CRM_CONTRACT_RELATION"."CNT"  ELSE NULL END,0)

④金额:

}{金额}'

四、仪表盘设计

将分析与仪表盘结合在一起,然后展示报表

五、展示报表

当选择【金额】时,

当选择【合同数】时

通过以上可以发现,我们的报表现在可以通过选择的【显示指标】不一致,显示不同的结果。

转载地址:http://tyavx.baihongyu.com/

你可能感兴趣的文章
FastDFS的配置、部署与API使用解读(1)Get Started with FastDFS
查看>>
分布式--Spring Boot 微服务框架
查看>>
关于FileZilla上传文件后服务器端文件与本地文件大小不一致的解决方法
查看>>
手写SpringMVC实战,一切从Spring底层源码分析开始
查看>>
Spring源码---BeanFactory的抽象
查看>>
XWiki 11.1 发布,协作式应用开发平台
查看>>
创建云数据库HybridDB for MySQL结果表
查看>>
关于SQL+NoSQL : NewSQL数据库
查看>>
从零开始一起学习SLAM | 相机成像模型
查看>>
一个老程序员的忠告:不要一辈子靠技术生存
查看>>
数据类型之间运算关系
查看>>
跳出面向对象思想(二) 多态
查看>>
WebStorm Exception: ...requested without authorization...
查看>>
Jenkins +selenium(学习笔记三十一)
查看>>
k8s使用ServiceAccount Token的方式访问apiserver
查看>>
C语言中用于计算数组长度的函数 “strlen() ”。
查看>>
微信公众平台中临时二维码的scene_id为32位非0整型
查看>>
《快学 Go 语言》第 5 课 —— 神奇的切片
查看>>
eclipse 导入maven项目 不识别web
查看>>
Java入门—集合
查看>>