You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Power BI任务统计需求:按CS代表统计并关联日历表筛选

解决方案

1. 统计每位CS代表的总任务数量

SQL实现

假设任务表名为task_list,包含cs_representative(CS代表)、task_id(任务ID)字段:

SELECT 
    cs_representative,
    COUNT(task_id) AS total_tasks
FROM task_list
GROUP BY cs_representative;

Excel/Power BI实现

插入数据透视表,将cs_representative拖到行区域,task_id拖到值区域并设置为计数。

2. 统计每位CS代表的各客户任务数量

SQL实现

假设任务表额外包含customer_name(客户名称)字段:

SELECT 
    cs_representative,
    customer_name,
    COUNT(task_id) AS customer_task_count
FROM task_list
GROUP BY cs_representative, customer_name
ORDER BY cs_representative, customer_task_count DESC;

Excel/Power BI实现

数据透视表中,将cs_representative拖到行区域,customer_name拖到行区域(置于CS代表字段下方),task_id拖到值区域设置为计数。

3. 关联日历表实现年月维度筛选

前提准备

确保日历表calendar_table包含date(日期)、year(年份)、month(月份,可设为数字或格式如'2024-03'的文本)字段。

SQL实现

关联任务表与日历表后按年月分组统计:

-- 各CS代表每月总任务数统计
SELECT 
    c.year,
    c.month,
    t.cs_representative,
    COUNT(t.task_id) AS monthly_total_tasks
FROM task_list t
JOIN calendar_table c ON DATE(t.task_date) = c.date
GROUP BY c.year, c.month, t.cs_representative
ORDER BY c.year, c.month, t.cs_representative;

-- 各CS代表每月各客户任务数统计
SELECT 
    c.year,
    c.month,
    t.cs_representative,
    t.customer_name,
    COUNT(t.task_id) AS monthly_customer_tasks
FROM task_list t
JOIN calendar_table c ON DATE(t.task_date) = c.date
GROUP BY c.year, c.month, t.cs_representative, t.customer_name
ORDER BY c.year, c.month, t.cs_representative, t.customer_name;

Excel/Power BI实现

  1. 建立关联:Power BI在模型视图中,将任务表的task_date与日历表的date设置为关联关系;Excel可通过Power Query合并两表,或用VLOOKUP将年月字段匹配到任务表。
  2. 筛选设置:在数据透视表中,将日历表的year和month拖到筛选器区域,即可通过选择年月筛选对应统计结果。

内容的提问来源于stack exchange,提问作者THough

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.14 20:02:42