我有以下数据源,其中包含一些票证状态。
我的目标是计算;"以前的状态";列,其中包含上一个状态开始时的时间戳。我的目标是在不使用表格计算的情况下计算它,这样我就可以制作药丸,任何人都可以在视图中使用它们。
有可能吗?我尝试了许多Lods函数,但没有得到任何有用的东西。
+--------+---------------------+---------------------+-------------------------+-------------------------+----------------------+
| Ticket | Status from | Status to | Status previous | Status current | Status previous from |
+--------+---------------------+---------------------+-------------------------+-------------------------+----------------------+
| A001 | NULL | 10/12/2022 13:40:00 | NULL | New | NULL |
| A001 | 10/12/2022 13:40:00 | 10/13/2022 10:00:00 | New | Ready | NULL |
| A001 | 10/13/2022 10:00:00 | 10/13/2022 11:27:03 | Ready | Development in progress | 10/12/2022 13:40:00 |
| A001 | 10/13/2022 11:27:03 | 10/14/2022 18:45:55 | Development in progress | Ready for tests | 10/13/2022 10:00:00 |
| A001 | 10/14/2022 18:45:55 | 10/14/2022 18:49:55 | Ready for tests | Tests in progress | 10/13/2022 11:27:03 |
| A001 | 10/14/2022 18:49:55 | 10/14/2022 19:38:00 | Tests in progress | Test passed | 10/14/2022 18:45:55 |
| A001 | 10/14/2022 19:38:00 | NULL | Test passed | Done | 10/14/2022 18:49:55 |
| A002 | NULL | 10/17/2022 1:42:56 | NULL | New | NULL |
| A002 | 10/17/2022 1:42:56 | 10/17/2022 18:44:44 | New | Ready | NULL |
| A002 | 10/17/2022 18:44:44 | 10/18/2022 6:05:05 | Ready | Development in progress | 10/17/2022 1:42:56 |
| A002 | 10/18/2022 6:05:05 | 10/18/2022 9:27:34 | Development in progress | Ready for tests | 10/17/2022 18:44:44 |
| A002 | 10/18/2022 9:27:34 | 10/18/2022 12:00:01 | Ready for tests | Tests in progress | 10/18/2022 6:05:05 |
| A002 | 10/18/2022 12:00:01 | 10/18/2022 12:01:01 | Tests in progress | Test failed | 10/18/2022 9:27:34 |
| A002 | 10/18/2022 12:01:01 | 10/18/2022 18:07:08 | Test failed | Development in progress | 10/18/2022 12:00:01 |
| A002 | 10/18/2022 18:07:08 | 10/18/2022 20:40:40 | Development in progress | Ready for tests | 10/18/2022 12:01:01 |
| A002 | 10/18/2022 20:40:40 | 10/18/2022 23:34:52 | Ready for tests | Tests in progress | 10/18/2022 18:07:08 |
| A002 | 10/18/2022 23:34:52 | 10/18/2022 23:44:11 | Tests in progress | Test passed | 10/18/2022 20:40:40 |
| A002 | 10/18/2022 23:44:11 | NULL | Test passed | Done | 10/18/2022 23:34:52 |
+--------+---------------------+---------------------+-------------------------+-------------------------+----------------------+
LOD表达式在这里不起作用,因为您希望在物理窗口中读取和使用数据。DateDiff不适合你吗?DateDiff('seconds',[Status from],[Status to])
Steve
表计算是Tableau中唯一可以考虑记录顺序的计算。聚合和LOD计算对无序的记录块进行操作,因此无法计算";与之前的";价值
如果你不想使用表计算——比如说,为了避免将大量详细的数据记录通过网络发送到客户端,你可以考虑通过自定义SQL使用窗口化(也称为分析(查询,或者使用预处理脚本预先计算该列。
SQL窗口化/分析查询非常适合用于此(和其他(目的,因此值得花时间学习。如果在Tableau中使用自定义SQL,我建议将其限制为在逻辑模型中创建一个明显的表/视图,并将其与其他表关联起来。您不必为所有内容创建一个庞大的自定义SQL批处理。
Tableau Prep在一定程度上支持一些有限的窗口/分析查询,但远低于SQL标准。Tableau的超级数据库通过其API支持窗口/分析查询,但不幸的是,我不相信你可以将自定义SQL与超级数据库一起使用。