How can I add a unique row number for every row in a Card (table)?

I am building a card that will have multiple rows.  For this example, the card will have 100 rows.  I would like to add a column that has a 'counter' 1-100 for each row.  What is the best way to add this to the card?

 

Thanks,

 

Matt

Comments

  • To this via a SQL transform:

     

    1st determine what you are going to order your card by to get the row number (rank). I'll use 'Volume' for my example.

     

    You can do the following to your current dataset to add a row number (rank) column. 

    Select 
    a.*
    ,@rank:= @rank + 1 AS `Rank`
    FROM `dataset` AS a, (SELECT @rank:=0) b
    ORDER BY `Volume` desc

    Then at the card level, make sure to sort by your new rank column and then add it to your table.

     

    Hope that helps,
    Valiant

     

    **Please mark "Accept as Solution" if this post solves your problem
    **Say "Thanks" by clicking the "heart" in the post that helped you.

  • or... via ETL

    1.png

     


    “There is a superhero in all of us, we just need the courage to put on the cape.” -Superman
This discussion has been closed.