# Perspective table columns in unpredictable order

**URL:** <https://forum.inductiveautomation.com/t/perspective-table-columns-in-unpredictable-order/86669>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [March 1, 2024, 10:20am UTC](https://forum.inductiveautomation.com/t/perspective-table-columns-in-unpredictable-order/86669 "2024-03-01T10:20:54Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![AGOSTINO\_SCLAUZERO](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@AGOSTINO\_SCLAUZERO](https://forum.inductiveautomation.com/u/AGOSTINO_SCLAUZERO)\
**Post date:** [March 1, 2024, 10:20am UTC](https://forum.inductiveautomation.com/t/perspective-table-columns-in-unpredictable-order/86669/1 "2024-03-01T10:20:55Z")

</div>

I have a perspective table in which the property 'data' is assigned the following binding script:

```
cols = ["A","B","C"]
rows = [[10, 20, 30]]		
return system.dataset.toDataSet(cols, rows)

```

The Table doesn't have any other property customized, in particular it doesn't have the columns array property assigned.  
What I get is:  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/e/3eab20b2337a92e600d2d7635932de73d006a9cb.png)

Now, let's shuffle the columns order:

```
cols = ["B","C","A"]
rows = [[20, 30, 10]]		
return system.dataset.toDataSet(cols, rows)

```

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/d/a/dae342879479bc8986776fcbaa700eadf721d987.png)

**The table seems to keep the column order provided in the dataset.**  
Now let's add another column:

```
cols = ["B","C","A", "10"]
rows = [[20, 30, 10, 40]]		
return system.dataset.toDataSet(cols, rows)

```

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/5/851050342c9394ff92af7e22327570dec4ad5d3e.png)

When the column name is a string that can be converted into a number, it goes at the beginning. Please don't say that the numbers come before letters because this would be if an ordering was going on, and that is not the case as I showed in my second example.  
This is relevant for my application because I'm generating a pivot that uses both numbers and strings as columns headers. As shown in my example, they are all handled as strings.

It seems to be a minor inconsistency in perspective's table component but it forces me to populate the columns list dinamically instead of using automatic columns generation.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [March 1, 2024, 10:33am UTC](https://forum.inductiveautomation.com/t/perspective-table-columns-in-unpredictable-order/86669/2 "2024-03-01T10:33:18Z")

</div>

Have you set the table's `column.X.field` properties to match the cols names? Doing this will force the column order.

---

<div class="post-metadata">

**Author:** ![AGOSTINO\_SCLAUZERO](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@AGOSTINO\_SCLAUZERO](https://forum.inductiveautomation.com/u/AGOSTINO_SCLAUZERO)\
**Post date:** [March 1, 2024, 10:34am UTC](https://forum.inductiveautomation.com/t/perspective-table-columns-in-unpredictable-order/86669/3 "2024-03-01T10:34:25Z")

</div>

As I mentioned, I'm not setting the columns. I'm exploiting the auto-generated columns.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [March 1, 2024, 10:50am UTC](https://forum.inductiveautomation.com/t/perspective-table-columns-in-unpredictable-order/86669/4 "2024-03-01T10:50:50Z")

</div>

In [Perspective - Table | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/appendix/components/perspective-components/perspective-display-palette/perspective-table#description) the columns property states,

> **field** : A string that matches this column config with a table column. This string must correspond to the default column name of the column. Value is string.

I think it's a bug. Even if I set all the `column.X.field` properties and specify an expression `"10"` to force it to a string (indicated by green value color) the sort order is incorrect.

I suggest you contact support.

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [March 1, 2024, 11:50am UTC](https://forum.inductiveautomation.com/t/perspective-table-columns-in-unpredictable-order/86669/5 "2024-03-01T11:50:06Z")

</div>

i mean you should never name a column after a number, that makes no sense

---

<div class="post-metadata">

**Author:** ![AGOSTINO\_SCLAUZERO](https://avatars.discourse-cdn.com/v4/letter/a/eada6e/32.png) [@AGOSTINO\_SCLAUZERO](https://forum.inductiveautomation.com/u/AGOSTINO_SCLAUZERO)\
**Post date:** [March 1, 2024, 11:53am UTC](https://forum.inductiveautomation.com/t/perspective-table-columns-in-unpredictable-order/86669/6 "2024-03-01T11:53:00Z")

</div>

but if it is a Pivot

---

<div class="post-metadata">

**Author:** ![victordcq](https://avatars.discourse-cdn.com/v4/letter/v/f6c823/32.png) [@victordcq](https://forum.inductiveautomation.com/u/victordcq)\
**Post date:** [March 1, 2024, 12:01pm UTC](https://forum.inductiveautomation.com/t/perspective-table-columns-in-unpredictable-order/86669/7 "2024-03-01T12:01:30Z")

</div>

you mean making your headers in the first column instead of the first row?  
whats a real example? (something that makes more sanse than ABC10)
