简体   繁体   English

如何在 Tableau 中对属于同一列值的行进行编号

[英]How to number rows belonging to the same column value in Tableau

I'm new to Tableau and I'm stuck.我是 Tableau 的新手,我被困住了。 I've something like this.我有这样的东西。

Ticket Theme Time门票主题时间
AB Red 23.6 AB红23.6
AB Red 12.9 AB红12.9
AC Red 15.0交流红 15.0
AD Yellow 12.1 AD 黄色 12.1
AD Yellow 23.1 AD 黄色 23.1
AD Yellow 11.0 AD 黄色 11.0

What i want is, I want to add a number column (named index) such that the first row of ticket AB has a column (index) value 0, second row will have a value 1 and so on.我想要的是,我想添加一个数字列(命名索引),以便票据 AB 的第一行的列(索引)值为 0,第二行的值为 1,依此类推。

Ticket Index Theme Time门票索引主题时间
AB 0 Red 23.6 AB 0红 23.6
AB 1 Red 12.9 AB 1红 12.9
AC 0 Red 15.0 AC 0红 15.0
AD 0 Yellow 12.1 AD 0黄色 12.1
AD 1 Yellow 23.1 AD 1黄色 23.1
AD 2 Yellow 11.0 AD 2黄色 11.0

Thanks in advance提前致谢

You have quite a few options.你有很多选择。 All table calculations so get familiar with those.所有表格计算,所以要熟悉这些。

There's the INDEX() function, but as you want your count to start at 0 and the index starts at 1 then simply -1:有 INDEX() function,但是因为你希望你的计数从 0 开始,索引从 1 开始,然后只是 -1:

INDEX()-1

Alternatively there's the FIRST() function.或者,还有 FIRST() function。 This starts at 0 but counts in -ve numbers so also requires a tweak:这从 0 开始,但计入 -ve 数字,因此还需要进行调整:

FIRST()*-1

You could also look at running_sum and running_count.您还可以查看 running_sum 和 running_count。 Either way you will need to edit the table calculation to restart every [Ticket]无论哪种方式,您都需要编辑表格计算以重新启动每个 [Ticket]

在此处输入图像描述

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM