简体   繁体   中英

How to number rows belonging to the same column value in Tableau

I'm new to Tableau and I'm stuck. I've something like this.

Ticket Theme Time
AB Red 23.6
AB Red 12.9
AC Red 15.0
AD Yellow 12.1
AD Yellow 23.1
AD Yellow 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.

Ticket Index Theme Time
AB 0 Red 23.6
AB 1 Red 12.9
AC 0 Red 15.0
AD 0 Yellow 12.1
AD 1 Yellow 23.1
AD 2 Yellow 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()-1

Alternatively there's the FIRST() function. This starts at 0 but counts in -ve numbers so also requires a tweak:

FIRST()*-1

You could also look at running_sum and running_count. Either way you will need to edit the table calculation to restart every [Ticket]

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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