# Get all rows from a table where a value is below a value

**URL:** <https://community.glideapps.com/t/get-all-rows-from-a-table-where-a-value-is-below-a-value/58000>\
**Category:** Ask for Help\
**Created:** [February 15, 2023, 8:32pm UTC](https://community.glideapps.com/t/get-all-rows-from-a-table-where-a-value-is-below-a-value/58000 "2023-02-15T20:32:46Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Krivo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/krivo/32/5363_2.png) [@Krivo](https://community.glideapps.com/u/Krivo)\
**Post date:** [February 15, 2023, 8:32pm UTC](https://community.glideapps.com/t/get-all-rows-from-a-table-where-a-value-is-below-a-value/58000/1 "2023-02-15T20:32:46Z")

</div>

Wonder if somebody can help with this use-case

Table which I want to look up information from:

| Item | Priority |
| --- | --- |
| item1 | 3 |
| item2 | 2 |
| item3 | 1 |
| item4 | 4 |
| item5 | 5 |
| item6 | 6 |
| item7 | 8 |
| item8 | 7 |
| item9 | 9 |
| item10 | 11 |
| item11 | 10 |
| item12 | 12 |

A rule tells that two items are occupied based on Priority column and cannot be chosen. Therefore items with priority 1 and 2 cannot be selected. The available items are therefore all items except item3 and item2.

I need to get the available rows to be used in another table. I want to display a comma separated list with all the available items. The list should be sorted alphabetically ascending order. item1, item4, item5, item6, item7, item8 etc.

Day1: Priority 1 and 2 cannot be chosen  
Day2: Priority 1,2,3,4 cannot be chosen  
Day3: Priority 1 cannot be chosen  
…  
Day14:Priority 1,2,3,4,5 cannot be chosen

I have considered using the Array Columns - but cannot get this working

---

<div class="post-metadata">

**Author:** ![Krivo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/krivo/32/5363_2.png) [@Krivo](https://community.glideapps.com/u/Krivo)\
**Post date:** [February 15, 2023, 10:24pm UTC](https://community.glideapps.com/t/get-all-rows-from-a-table-where-a-value-is-below-a-value/58000/2 "2023-02-15T22:24:08Z")

</div>

Made a workaround - not very nice. Would like to do it a **lot** easier. So if you know how, please share 🙂

**Workaround**  
Extra column added to table A

_TABLE A:_

> | Item| Priority| Priority\_item|  
> | ----------- | ----------- | -----------|  
> | item1| 3| @03@item1|  
> | item2| 2| @02@item2|  
> | item3| 1| @01@item3|  
> | item4| 4| @04@item4|  
> | item5| 5| @05@item5|  
> | item6| 6| @06@item6|  
> | item7| 8| @08@item7|  
> | item8| 7| @07@item8|  
> | item9| 9| @09@item9|  
> | item10| 11|@11@item10|  
> | item11| 10|@10@item11|  
> | item12| 12|@12@item12|

_TABLE B:_  
Added a relation and lookup to get all items from Table A

Added a Array sort colum based on Priority\_item which will get the items sorted alphabetically - meaning in priority order like :

> @01@item3, @02@item2, @03@item1 etc

The Priority number was two (meaning taking out priority 1 and 2)  
Added a Slice array column to go to third item (remember item numbers start at 0 - 0,1,2) in the array thereby removing the two first items

Added a Joined list to make it a comma separated list  
Added a template column to remove @01@, @02,…@20@ with nothing

Result is:  
item1, item4, item5, item6, item7, item8 etc

Would be great with an ORDER BY functionality

---

<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:** [February 15, 2023, 11:40pm UTC](https://community.glideapps.com/t/get-all-rows-from-a-table-where-a-value-is-below-a-value/58000/3 "2023-02-15T23:40:36Z")

</div>

> [@Krivo](#):
>
> Day1: Priority 1 and 2 cannot be chosen  
> Day2: Priority 1,2,3,4 cannot be chosen  
> Day3: Priority 1 cannot be chosen

Can you explain why it changes to just “priority 1” here in the 3rd day?

I was thinking you can use a boolean column and make a relation based on a “true” value but I might need to understand your use case more.

---

<div class="post-metadata">

**Author:** ![Robert\_Petitto](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/robert_petitto/32/25193_2.png) [@Robert\_Petitto](https://community.glideapps.com/u/Robert_Petitto)\
**Post date:** [February 16, 2023, 12:33am UTC](https://community.glideapps.com/t/get-all-rows-from-a-table-where-a-value-is-below-a-value/58000/4 "2023-02-16T00:33:11Z")

</div>

Ya that’s what I was going to suggest:

> [@link Conditional Relations (and Relations as Conditions!)](https://community.glideapps.com/t/conditional-relations-and-relations-as-conditions/52295):
>
> By popular request, I created a follow-up video to my Glide Relation Basics tutorial about how to set up… conditional relations relations as conditions navigation through relations Enjoy! [[Glide: Conditional Relations (and Relations as Conditions!)] ](https://www.youtube.com/watch?v=K8iRKOr55i4) Here’s a link to the first part in case you missed it:

---

<div class="post-metadata">

**Author:** ![Krivo](https://sea2.discourse-cdn.com/flex002/user_avatar/community.glideapps.com/krivo/32/5363_2.png) [@Krivo](https://community.glideapps.com/u/Krivo)\
**Post date:** [February 16, 2023, 8:38am UTC](https://community.glideapps.com/t/get-all-rows-from-a-table-where-a-value-is-below-a-value/58000/5 "2023-02-16T08:38:52Z")

</div>

@ThinhDinh it has to do with reservation of items. On day 1 two people have made reservation. Day 2 three reservations. Day 3 one reservation.  
Which items are available and in what sequence to make them available is based on the priority column. So on day3 item2 should be the first item in the list.

When I want to display the items in a comma separated list I’m challenged as the relation and lookup will just return the list in the order of the table and this is not sorted

If the table was sorted in priority order then the returned list would be fine. But the table is also used for other things and actually I would like the table to be sorted by items alphabetically as this makes the list easier to maintain

Does it make sense ?
