1

我想在不同的时间段内找到以小时为单位的总持续时间。IE。一旦我添加了诸如“十月”之类的过滤器,它应该会显示该月的总小时数。我想将多个参加者的重复课程计为 1 节课。IE。教授该科目所花费的时间。

 Date        Duration  Subject   Attendee
 1/10/2019     2:00    Math       Joe Bloggs
 1/10/2019     2:00    Math       John Doe
 2/10/2019     3:00    English    Jane Doe
 6/11/2019     1:00    Geog       Jane Roe
 17/12/2019    0:30    History    Joe Coggs

我想要花在这些主题上的总时间。这意味着上述总时长应加起来为 6:30,因为两节数学课只能算作 1 节课(2 小时)。我如何编写一个表达式来生成我们整体学习的 KPI,然后还允许我向下钻取到月份和日期。提前致谢

4

1 回答 1

2

可以建议您创建另一个包含不同值的表(我假设唯一的组合是Date <-> Subject

下面的脚本将创建OverallDuration表,其中包含组合的不同持续时间值Date <-> Subject。这样,您将拥有一个OverallDuration可在 KPI 中使用的附加字段。

OverallDuration表格链接到RawData表格(它本身链接到表格),这Calendar意味着OverallDuration计算将尊重Subject,LessonYear等上的选择LessonMonth(请看Math下面的选择图片)

RawData:
Load
  *,
  // Create a key field with the combination of Date and Subject
  Date & '_' & Subject as DateSubject_Key
;
Load * Inline [
Date,          Duration, Subject,  Attendee
1/10/2019,     2:00,     Math,     Joe Bloggs
1/10/2019,     2:00,     Math,     John Doe
2/10/2019,     3:00,     English,  Jane Doe
6/11/2019,     1:00,     Geog,     Jane Roe
17/12/2019,    0:30,     History,  Joe Coggs
];

// Load distinct DateSubject_Key and the Duration
// converting the duraion to time.
// This table will link to RawData on the key field
OverallDuration:
Load
  Distinct
  DateSubject_Key,
  time(Duration)          as OverallDuration
Resident
  RawData
;

// Creating calendar table from the dates (distinct) 
// from RawData and creating two additional fields - Month and Year
// This table will link to RawData on Date field
Calendar:
Load
  Distinct
  Date,
  Month(Date)             as LessonMonth,
  Year(Date)              as LessonYear
Resident
  RawData
;  

重新加载上面的脚本后,您的表达式将只是sum( OverallDuration )您可以在下面的数据透视表中看到结果:

结果数据透视表

总持续时间为06:30小时,持续时间Math02:00小时:

选定的数学科目

您的数据模型将如下所示:

数据模型

我喜欢将我的日历数据保存在单独的表中,但如果需要,您可以将月份和年份字段添加到主表中

于 2019-10-06T16:34:53.070 回答