# Pivot table using relations

**URL:** <https://community.glideapps.com/t/pivot-table-using-relations/30981>\
**Category:** Ask for Help\
**Created:** [August 26, 2021, 11:04am UTC](https://community.glideapps.com/t/pivot-table-using-relations/30981 "2021-08-26T11:04:53Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lin\_Altshuler](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/lin_altshuler/32/32591_2.png) [@Lin\_Altshuler](https://community.glideapps.com/u/Lin_Altshuler)\
**Post date:** [August 26, 2021, 11:04am UTC](https://community.glideapps.com/t/pivot-table-using-relations/30981/1 "2021-08-26T11:04:53Z")

</div>

Hi guys,  
How can I pivot my glide table using only relations within the table and lookup columns?  
The UserID is also stored as the ViewingUser based on the signed in user column.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/e/f/ef316d4083ebe7c53f8c06191079ae1d965761d9.png)

I started thinking about row numbers as templates with the RowID somehow…  
Any suggestions?  
Thanks

---

<div class="post-metadata">

**Author:** ![ThinhDinh](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/thinhdinh/32/49_2.png) [@ThinhDinh](https://community.glideapps.com/u/ThinhDinh)\
**Post date:** [August 26, 2021, 11:37am UTC](https://community.glideapps.com/t/pivot-table-using-relations/30981/2 "2021-08-26T11:37:26Z")

</div>

Can you go into more details on what exactly do you want to pivot?

---

<div class="post-metadata">

**Author:** ![Lin\_Altshuler](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/lin_altshuler/32/32591_2.png) [@Lin\_Altshuler](https://community.glideapps.com/u/Lin_Altshuler)\
**Post date:** [August 26, 2021, 11:50am UTC](https://community.glideapps.com/t/pivot-table-using-relations/30981/3 "2021-08-26T11:50:34Z")

</div>

Yes,  
Its a little complicated.  
I have a measurement table that holds data that the users insert and is viewed by their trainer.  
I need to show the data as a table with multiple columns but I have only 2 columns component in glide.  
so I use a quickchart to create a table for each row  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/8/9/8929e2859976f78444e322b8852098e84529117e.png) example  
and because the inline list cards or tiles option crops the image and has no “show all image” option I can only show them as images.  
so I need all the data of the viewed user in one row.  
I am limiting to 10 rows.  
What I need:  
![image|652x500](upload://mqw

 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/1/8/1827d78830b8f34ef321143b83464c70d40226a3.png)  
 ![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/9/d/9d2f7a85ee5a835bb77ad57f148bed801ff72b63.png)

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [August 26, 2021, 12:02pm UTC](https://community.glideapps.com/t/pivot-table-using-relations/30981/4 "2021-08-26T12:02:37Z")

</div>

You should be able to achieve that using a HTML or CSS table, and display it in a rich text component.  
If the data for each row comes from a single column, you can construct each table row using a combination of template, if-then-else and joined list columns.

---

<div class="post-metadata">

**Author:** ![Lin\_Altshuler](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/lin_altshuler/32/32591_2.png) [@Lin\_Altshuler](https://community.glideapps.com/u/Lin_Altshuler)\
**Post date:** [August 26, 2021, 12:03pm UTC](https://community.glideapps.com/t/pivot-table-using-relations/30981/5 "2021-08-26T12:03:48Z")

</div>

Can I have the syntax for that? I am not a code person.  
I get this but how do I put the data in?

table { width: 100%; border-collapse: collapse; border: 1px solid black; }
## Single Border Around The Table

| Firstname | Lastname |
| --- | --- |
| Peter | Griffin |
| Lois | Griffin |

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [August 26, 2021, 12:15pm UTC](https://community.glideapps.com/t/pivot-table-using-relations/30981/6 "2021-08-26T12:15:44Z")

</div>

If we use that as an example, you’d first have a template column to build each table row, something like:

`<tr><td>{first}</td><td>{last}</td></tr>`

And then use replacements to insert the names for each row;

```auto
Firstname -> {first}
Lastname -> {last}

```

Then use a joined list column (with an empty separator) to join all the rows together.  
Finally, wrap that joined list in a table using another template column:

`<table>{jl-rows}</table>`

That’s the basic idea. Obviously it can get a lot more complicated than that. If you need to filter the rows, you can do that with extra templates, relations (sometimes) and if-then-else columns.

And if you want nice looking tables, take a look at [HTML Table Styler ▦ CSS Generator | 𝗗𝗜𝗩𝗧𝗔𝗕𝗟𝗘.𝗖𝗢𝗠](https://divtable.com/table-styler/)

---

<div class="post-metadata">

**Author:** ![Lin\_Altshuler](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/lin_altshuler/32/32591_2.png) [@Lin\_Altshuler](https://community.glideapps.com/u/Lin_Altshuler)\
**Post date:** [August 26, 2021, 12:17pm UTC](https://community.glideapps.com/t/pivot-table-using-relations/30981/7 "2021-08-26T12:17:00Z")

</div>

Thant’s awesome .  
Thank you!

---

<div class="post-metadata">

**Author:** ![Lin\_Altshuler](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/lin_altshuler/32/32591_2.png) [@Lin\_Altshuler](https://community.glideapps.com/u/Lin_Altshuler)\
**Post date:** [August 26, 2021, 12:53pm UTC](https://community.glideapps.com/t/pivot-table-using-relations/30981/8 "2021-08-26T12:53:43Z")

</div>

![image](https://us1.discourse-cdn.com/flex002/uploads/glideapps/original/3X/2/2/22b9cb7b181bcdc4c0e511cd24fa67346486d61e.png)  
😀 😀 😀

---

<div class="post-metadata">

**Author:** ![Darren\_Murphy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/darren_murphy/32/47326_2.png) [@Darren\_Murphy](https://community.glideapps.com/u/Darren_Murphy)\
**Post date:** [August 26, 2021, 2:14pm UTC](https://community.glideapps.com/t/pivot-table-using-relations/30981/9 "2021-08-26T14:14:43Z")

</div>

Wonderful!!  
Nice work 👍

---

<div class="post-metadata">

**Author:** ![NoCodeAndy](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/nocodeandy/32/62530_2.png) [@NoCodeAndy](https://community.glideapps.com/u/NoCodeAndy)\
**Post date:** [January 17, 2024, 4:50pm UTC](https://community.glideapps.com/t/pivot-table-using-relations/30981/10 "2024-01-17T16:50:52Z")

</div>


