在 Tableau 的同一时间间隔内将 Table 1 的计数除以 Table 2 的计数

Divide count of Table 1 by count of Table 2 on the same time interval in Tableau

我有两个带有 ID 和时间戳的表。 Table 1 有两列:ID 和 created_at。 Table 2 有两列:ID 和 post_date。我想在 Tableau 中创建一个图表,显示 Table 1 中的记录数除以 Table 2 中的记录数,按周计算。我怎样才能做到这一点?

一种方法可能是像这样使用自定义 SQL 为您的可视化创建新的数据源:

SELECT created_table.created_date,
   created_table.created_count,
   posted_table.posted_count
FROM (SELECT TRUNC (created_at) AS created_date, COUNT (*) AS created_count
      FROM Table1) created_table
   LEFT JOIN
   (SELECT TRUNC (post_date) AS posted_date, COUNT (*) AS posted_count
      FROM Table2) posted_table
       ON created_table.created_date = posted_table.posted_date

这将为您提供两个表中这些日期的日期和计数,您可以在可视化中使用 Tableau 的日期函数对其进行分组。我将 created_table 作为左联接的第一部分,假设某些记录将被创建但不会发布,但没有创建就没有帖子。如果不是这种情况,您将需要不同的连接。