# Perspective - Table Columns with Sub Keys

**URL:** <https://forum.inductiveautomation.com/t/perspective-table-columns-with-sub-keys/77310>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [August 2, 2023, 7:35pm UTC](https://forum.inductiveautomation.com/t/perspective-table-columns-with-sub-keys/77310 "2023-08-02T19:35:43Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![j.israelsen](https://avatars.discourse-cdn.com/v4/letter/j/ad7895/32.png) [@j.israelsen](https://forum.inductiveautomation.com/u/j.israelsen)\
**Post date:** [August 2, 2023, 7:35pm UTC](https://forum.inductiveautomation.com/t/perspective-table-columns-with-sub-keys/77310/1 "2023-08-02T19:35:43Z")

</div>

Utilizing Perspective, let's say I have data in the following form (an array of dictionaries with sub-dictionaries):

> [  
> {  
> "value1": "value",  
> "sub\_dict": {  
> "value2": "value",  
> "value3": "value"  
> }  
> },  
> {  
> "value1": "value",  
> "sub\_dict": {  
> "value2": "value",  
> "value3": "value"  
> }  
> }  
> ]

I want to display this in a table such that I have columns for "value1", "value2", and "value3". I can get "value1" to show up as a column in the table **but I'm having troubles getting the keys in the "sub\_dict" to show up as columns in the table** (see attached picture sample). Is there some special syntax? Is this even possible? Note, I can get "sub\_dict" to show up as a column, but I really want the keys within that dictionary, not the entire dictionary.

![sample_table_column](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/5/55ace590fb409a4d8037ffbd17164ac5b0265763.png)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [August 2, 2023, 7:39pm UTC](https://forum.inductiveautomation.com/t/perspective-table-columns-with-sub-keys/77310/2 "2023-08-02T19:39:15Z")

</div>

No, you can't _really_ do this. You could give `sub_dict` a custom renderer view that 'fakes' having multiple columns (not super well), but there's no way to get the table to do this without flattening your data at the source.

---

<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:** [August 2, 2023, 7:58pm UTC](https://forum.inductiveautomation.com/t/perspective-table-columns-with-sub-keys/77310/3 "2023-08-02T19:58:19Z")

</div>

You could convert it to a list suitable for the table data using a script. Try pasting this into the Designer Script Console.

```auto
myData = [
	{
		"value1": "valueA1",
		"sub_dict": {
			"value2": "valueA2",
			"value3": "valueA3"
		}
	},
	{
		"value1": "valueB1",
		"sub_dict": {
			"value2": "valueB2",
			"value3": "valueB3"
		}
	}
]

def convertToList(data):
	output = []
	for datum in data:
		value1 = datum['value1']
		value2 = datum['sub_dict']['value2']
		value3 = datum['sub_dict']['value3']
		output.append([value1, value2, value3])
	return output

convertToList(myData)

```

---

<div class="post-metadata">

**Author:** ![j.israelsen](https://avatars.discourse-cdn.com/v4/letter/j/ad7895/32.png) [@j.israelsen](https://forum.inductiveautomation.com/u/j.israelsen)\
**Post date:** [August 2, 2023, 8:02pm UTC](https://forum.inductiveautomation.com/t/perspective-table-columns-with-sub-keys/77310/4 "2023-08-02T20:02:24Z")

</div>

@Transistor, yes, thank you for the idea. I think I'm going to have to do something very similar to what you proposed.

---

<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:** [August 2, 2023, 8:03pm UTC](https://forum.inductiveautomation.com/t/perspective-table-columns-with-sub-keys/77310/5 "2023-08-02T20:03:52Z")

</div>

You're welcome.

Tip: when posting code ...

 ![Formatting code](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/0/70741738ea3cbbe8a2d249e1194c80035567335c.png)

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [August 2, 2023, 8:07pm UTC](https://forum.inductiveautomation.com/t/perspective-table-columns-with-sub-keys/77310/6 "2023-08-02T20:07:28Z")

</div>

You could unwrap one layer with this expression:

```auto
forEach(
	{path.to.source.data},
	asMap(
		asPairs(
			asMap('value1', it()['value1']),
			it()['sub_dict')
		)
	)
)

```

---

<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:** [August 2, 2023, 8:24pm UTC](https://forum.inductiveautomation.com/t/perspective-table-columns-with-sub-keys/77310/7 "2023-08-02T20:24:31Z")

</div>

> [@pturmel](#):
>
> You could unwrap one layer with this expression:

Yes, but who would understand it? Not me!
