Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
callum
Helper II
Helper II

How come table columns get sorted alphabetically and not by their position in capabilities.json?

Hello,

 

Here's my capabilities.json:

 

{
  "dataRoles": [
    {
      "displayName": "Name",
      "name": "name",
      "kind": "Grouping"
    },
    {
      "displayName": "Description",
      "name": "description",
      "kind": "Grouping"
    },
    {
      "displayName": "Sector",
      "name": "sector",
      "kind": "Grouping"
    },
    {
      "displayName": "Ring",
      "name": "ring",
      "kind": "Grouping"
    },
    {
      "displayName": "Is new?",
      "name": "isNew",
      "kind": "Grouping"
    }
  ],
  "dataViewMappings": [
    {
      "table": {
        "rows": {
          "select": [
            {
              "for": {
                "in": "name"
              }
            },
            {
              "for": {
                "in": "description"
              }
            },
            {
              "for": {
                "in": "sector"
              }
            },
            {
              "for": {
                "in": "ring"
              }
            },
            {
              "for": {
                "in": "isNew"
              }
            }
          ]
        }
      }
    }
  ]
}

However, in my visual, when I run console.log(dataViews[0].table.rows), I see that for each row, it provides the description first, then isNew, name and ring, and finally sector. I presume it is sorting these alphabetically rather than a random sort and it appearing this way by coincidence - but either way, the fact remains that this order is pretty much useless to me as a developer.

 

In fact, it's not even sorted by the column names that I define - it's sorted by the column names that the user defines.

 

I would expect that because I defined name first in capabilities.json, it would appear as the first column of each row, so for example to get the name of the first row I would use dataViews[0].table.rows[0][0]. But with this method of ordering I don't actually know what index the name will be at.

 

How do I get around this issue?

Thanks.

1 ACCEPTED SOLUTION
v-chuncz-msft
Community Support
Community Support

@callum,

 

Check "options.dataViews[0].table.columns[0].roles".

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-chuncz-msft
Community Support
Community Support

@callum,

 

Check "options.dataViews[0].table.columns[0].roles".

Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.