Tableau:计算字段,用于将奇数系列转换为数字序列

时间:2019-02-14 17:24:48

标签: tableau tableau-online

在计算Tableau中的字段(准确地说是Tableau Prep)时,我需要您的帮助。

我有一个名为[代码顺序]的字段,该字段仅多次包含一系列奇数(1、3、5、7、9,..),这意味着它可以是(1,3,1,3,5,7,1,1,1,3,5,7,9,11)

我需要的是将它们转换为正常的数字序列,因此对于上面的示例,我需要:(1,2,1,2,3,4,1,1,1,2,3,4,5,6)

换句话说,按照[代码顺序],我有:

1 = 1
3 = 2
5 = 3
7 = 4
9 = 5
11 = 6
13 = 7
15 = 8
...
365 = 183

目前,我的最大值是365,即位置183,如果可能的话,我想避免输入182 IF公式。 ;)

在此先感谢您的帮助。 CYA

Plt.K

3 个答案:

答案 0 :(得分:1)

如果您的Code Order系列在此过程中缺少任何值,则可能会更准确。

示例系列:

enter image description here

备用字段:

enter image description here

Tableau设置:

enter image description here

答案 1 :(得分:0)

您要使用index()计算字段。创建一个名为index的新字段。计算结果仅为index()

enter image description here

[Code Order]添加到行架子,并将index添加到标签。您应该会看到类似这样的内容。

enter image description here

答案 2 :(得分:0)

以下计算应该可以解决问题

print(lst)