# Calculating a unique row int (not unique ID)

**URL:** <https://community.fibery.io/t/calculating-a-unique-row-int-not-unique-id/4931>\
**Category:** Get Help\
**Created:** [August 9, 2023, 6:53am UTC](https://community.fibery.io/t/calculating-a-unique-row-int-not-unique-id/4931 "2023-08-09T06:53:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![anadin](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/anadin/32/5376_2.png) [@anadin](https://community.fibery.io/u/anadin)\
**Post date:** [August 9, 2023, 6:53am UTC](https://community.fibery.io/t/calculating-a-unique-row-int-not-unique-id/4931/1 "2023-08-09T06:53:47Z")

</div>

Curious if anyone has an idea for this one, I’d like to use an unsorted table view (or did) to move items up and down and calculate their visible row number and put it in a row field. (basically I want to have a unique and intentional sort order that I create by dragging and dropping. Any ideas?

Thanks!

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [August 9, 2023, 6:58am UTC](https://community.fibery.io/t/calculating-a-unique-row-int-not-unique-id/4931/2 "2023-08-09T06:58:04Z")

</div>

Both list view and the new grid view allow drag and drop re-ordering.

Out of interest, why do you want/need to get the position (number) of an entity in a given view and put it as a field value for each entity?

---

<div class="post-metadata">

**Author:** ![Chr1sG](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/chr1sg/32/3941_2.png) [@Chr1sG](https://community.fibery.io/u/Chr1sG)\
**Post date:** [August 9, 2023, 7:02am UTC](https://community.fibery.io/t/calculating-a-unique-row-int-not-unique-id/4931/3 "2023-08-09T07:02:17Z")

</div>

Related

> [@How to access entities' "natural sort order" in Rules/Buttons/scripts?](https://community.fibery.io/t/how-to-access-entities-natural-sort-order-in-rules-buttons-scripts/1967):
>
> Entities can be (re)ordered manually via dragging (i.e. in a Card or List view). How can such entities’ relative order be determined or set in a Rule/Button/script?

> [@Can we translate the ranking number to a normal number?](https://community.fibery.io/t/can-we-translate-the-ranking-number-to-a-normal-number/4793):
>
> Hi, What we are trying to achieve is the following: We have a list with entities We want ‘normal numbers’ in the #Volgorde field So first entity is 1, last entity is 12 If an entity is added or removed, then also update that number So via script we received the ranking number. But what is the next step to translate that ranking number to the ‘ranking field’ (so numbers 0 - 12?) sweat_smile End goal: in automations we want to use that ranking number to determine if we should upda…

---

<div class="post-metadata">

**Author:** ![Matt\_Blais](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/matt_blais/32/1464_2.png) [@Matt\_Blais](https://community.fibery.io/u/Matt_Blais)\
**Post date:** [August 9, 2023, 2:29pm UTC](https://community.fibery.io/t/calculating-a-unique-row-int-not-unique-id/4931/4 "2023-08-09T14:29:08Z")

</div>

> [@anadin](#):
>
> calculate their visible row number

This is not possible in general, since View filters can change which entities are displayed – so in different Views, a particular entity’s “row number” could be different (and it might not even be displayed).

Within a script you can access the hidden `Rank` field, which reflects each entity’s displayed _relative order_ in unsorted views (see links posted above by @Chr1sG).

The Rank hidden field is changed by drag-re-ordering entities in a List view.

---

<div class="post-metadata">

**Author:** ![njyo](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/njyo/32/923_2.png) [@njyo](https://community.fibery.io/u/njyo)\
**Post date:** [August 11, 2023, 2:47pm UTC](https://community.fibery.io/t/calculating-a-unique-row-int-not-unique-id/4931/5 "2023-08-11T14:47:43Z")

</div>

I was thinking about something similar to build my [card-sort Grid View](https://community.fibery.io/t/new-view-type-gallery-view/4830/2) (yes, needs a different name).

Technically, if I give an entity `X` and `Y` number single-select fields, I could use those on a Board View as coordinates and then drag cards around as I want. Only problem is that new numbers aren’t being added automatically, but would need to be done manually…

---

<div class="post-metadata">

**Author:** ![anadin](https://sea2.discourse-cdn.com/flex020/user_avatar/community.fibery.io/anadin/32/5376_2.png) [@anadin](https://community.fibery.io/u/anadin)\
**Post date:** [August 29, 2023, 3:16am UTC](https://community.fibery.io/t/calculating-a-unique-row-int-not-unique-id/4931/6 "2023-08-29T03:16:49Z")

</div>

So I want to do this for export reasons we are using a DB as a data source for a game. Due to the nature of adding/removing items over time the DB is not in the right order so I can’t use their unique id. We are willing to drag and drop things into an order in one view and the copy that row order into a field of each of the DB entities. We have resorted to just doing it manually for now but I’ll come back and look into the rank thing sometime
