Tableau - 如何将值与上个月的 12 相加
Tableau - How sum values with 12 last months
在 Tableau 中,我有一个 table 这种形式:
行:分数。
列:我的(月),总和(好),总和(差)。
这是我使用时的信息:201811月
201611 201612 ... 201801 ... 201811 TOTAL
Score Good Bad Good Bad Good Bad ... Good Bad
1 3 0 7 3 6 3 2 1
2 5 1 1 1 1 1 4 4
3 10 3 2 1 0 3 3 3
我想使用带有 'Month' 列的过滤器,当我过滤 month=201811 时,从 201611 到 201711(过去 12 个月)在总计列(坏列和好列的总计)中按分数显示。
Filter: 201811
Formula: sum(Good) and sum(Bad) since '201611' to '201711'
我尝试 "IF DATEDIFF('month', [Good], today()) <=12" 但没有用。
感谢您的帮助。
试试这个:
If DATEDIFF("month",TODAY(),[Your Date Field],"Sunday") <= -12
then [Your Date Field] else null end
然后将其用作您的日期列。 "Sunday" 应该是您认为的一周的起始日。我不确定您的日期字段的名称,所以我将其命名为“[您的日期字段]”
在 Tableau 中,我有一个 table 这种形式:
行:分数。
列:我的(月),总和(好),总和(差)。
这是我使用时的信息:201811月
201611 201612 ... 201801 ... 201811 TOTAL
Score Good Bad Good Bad Good Bad ... Good Bad
1 3 0 7 3 6 3 2 1
2 5 1 1 1 1 1 4 4
3 10 3 2 1 0 3 3 3
我想使用带有 'Month' 列的过滤器,当我过滤 month=201811 时,从 201611 到 201711(过去 12 个月)在总计列(坏列和好列的总计)中按分数显示。
Filter: 201811
Formula: sum(Good) and sum(Bad) since '201611' to '201711'
我尝试 "IF DATEDIFF('month', [Good], today()) <=12" 但没有用。
感谢您的帮助。
试试这个:
If DATEDIFF("month",TODAY(),[Your Date Field],"Sunday") <= -12
then [Your Date Field] else null end
然后将其用作您的日期列。 "Sunday" 应该是您认为的一周的起始日。我不确定您的日期字段的名称,所以我将其命名为“[您的日期字段]”