[英]Tableau calculated field, with specific condition
I have a table in tableau with such columns:我在 tableau 中有一个包含这些列的表:
sender_id - id of sender, not unique in the table sender_id - 发件人的 id,在表中不是唯一的
date = date of sending.日期 = 发送日期。
For example:例如:
sender_id | date
------------------
11111 | 01.01.2020
11111 | 02.02.2020
22222 | 03.01.2020
33333 | 05.01.2020
44444 | 03.02.2020
I need to create a calculated field, which will determine whether this sender_id made a sending after 01.02.我需要创建一个计算字段,它将确定此 sender_id 是否在 01.02 之后发送。 It should look like this:
它应该如下所示:
sender_id | date | calculated_field
----------------------------------------
11111 | 01.01.2020 | 1
11111 | 02.02.2020 | 1
22222 | 02.01.2020 | null
33333 | 02.01.2020 | null
44444 | 03.02.2020 | 1
How could I do this?我怎么能这样做?
If the first value of sender_id actually should be null (ie: that the date is in focus to know), then this formula will give you correct:如果 sender_id 的第一个值实际上应该是 null (即:日期是重点知道的),那么这个公式会给你正确的:
Calc1 Calc1
IF date > DATE("2020-02-01") THEN 1 END
If you want to know per sender_id (looking at all the dates and then determine the latest date) then this should give you correct:如果您想知道每个 sender_id(查看所有日期,然后确定最新日期),那么这应该给您正确的:
Calc2 Calc2
IF { FIXED [sender_id]:MAX([date])} > DATE("2020-02-01") THEN 1 END
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.