0

How to create a column in a view with a sequential row number

I have searched the forum and did not find anything that directly answers this.

i have a table with two columns gross and net values.  I created two views each sorted by the Gross value and the net values.  I would like to add a new column to each view and have the value start at 1 in row one through x number of rows incrementing by 1 for each row.

example of the gross view.  The net view would also have 4 rows but different order.

Place   Gross

1            10

2            13

3            17

4            22

9 replies

null
    • szormpas
    • 2 mths ago
    • Reported - view

     Hi,

    Take a look at this post and see if it's what you're looking for.

      • gyannes
      • 2 mths ago
      • Reported - view

       

      • gyannes
      • 2 mths ago
      • Reported - view

       saw that post does not work for my setup. 

      • szormpas
      • 2 mths ago
      • Reported - view

        don't you ask for row numbering in a view element?

      • gyannes
      • 2 mths ago
      • Reported - view

       ok I inserted your code as follows.  And it worked for everything except if there is a duplicate the sequence numbers are out of synch. Notice in Gross there are two 82’s but GP (gross place) is 5,4 instead of 4,5.  Same happened for Net view for Net 73.

      The code i used follows the image

      let t := this;
      let arrayIDs := for loop1 in (select Players).Playsheet order by number(Players.Playsheet.Gross) do
              loop1.Id
          end;
      let i := 0;
      while item(arrayIDs, i) != t.Id do 
          i := i + 1
      end
      ;
      i + 1

      Additional info so I thought line 4 loop1.Id should be loop1.Players.Playsheet.Gross but then all values in GP become 1

      Then i tried to also t.Id in line 7 to the Gross field as well but Ninox locks up such that I can’t save the change.  I need to close the Ninox app and all changes are lost.

      • szormpas
      • 2 mths ago
      • Reported - view

        Hi,

      You're ascending on the gross and net columns, but I think you'll get the result you're looking for if you ascend on the GP and NP columns instead.

    • gyannes
    • 2 mths ago
    • Reported - view

    I read all the replies in that post and comments about using a select table could be an issue. I was hoping to see if anyone else had an option to try. 

    • Alain_Fontaine
    • 2 mths ago
    • Reported - view

    The necessity to use a "select" depends on the structure of your database.

    To add a row counter, in a context where a "select" is unavoidable, I use:

    let myt := Text;
    cnt(select Table where Text < myt) + 1
    
    • szormpas
    • 1 mth ago
    • Reported - view

    Hi, just thought I'd let you know that you can also display an index column using the View Widget.

Content aside

  • Status Answered
  • 1 mth agoLast active
  • 9Replies
  • 81Views
  • 4 Following