1

I created a new SharePoint list from an excel file. in the excel file I had ID column which held a sequential number added automatically. I don't want this column to be entered manually so I used the ID column in SharePoint list, the issue is that if I delete a row it will skip that ID in the next entry.

To solve this I added a new column and used JSON formatting to add a sequential number automatically:

{
  "$schema": "https://developer.microsoft.com/json-schemas/sp/v2/column-formatting.schema.json",
  "elmType": "div",
  "children": [
    {
      "elmType": "span",
      "txtContent": {
        "operator": "+",
        "operands": [
          "@rowIndex",
          1
        ]
      }
    }
  ]
}

So now the new column "#BMT" looks like:

enter image description here

The issue is, I want to show the number in descending order as it was in the excel file. How can I do that?

1 Answer 1

1

I don't think you can get the @rowIndex in descending order using JSON formatting as:

@rowIndex will always evaluate to the rendered index of a row within a view. This value is based on render position and will remain consistent based on position even as views are sorted and filtered. Indexes start at 0.

Documentation: @rowIndex

4
  • Then is there a different way to do it?
    – user105279
    Commented Sep 21, 2022 at 8:20
  • Using ID or any other number column is one way to do it. But you will face the same issue again when any item is deleted. Commented Sep 21, 2022 at 8:29
  • Or create a number column in list and run a scheduled power automate daily in off hours which will read all items from list and update number column for each list item one by one. Then use descending sorting on number column as per your requirements. Commented Sep 21, 2022 at 8:31
  • Hi @user105279, does this help you in any way? If yes, please Upvote(^) and accept as an Answer as it helped you & it will help others with similar question in future to find the correct answer easily. It also removes this question from "Unanswered questions" list. Commented Oct 13, 2022 at 11:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.