# Tables and Object in context clarification

**URL:** <https://community.appfarm.io/t/tables-and-object-in-context-clarification/190>\
**Category:** Bug reports\
**Created:** [January 17, 2023, 9:30am UTC](https://community.appfarm.io/t/tables-and-object-in-context-clarification/190 "2023-01-17T09:30:12Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![torstro](https://avatars.discourse-cdn.com/v4/letter/t/5daacb/32.png) [@torstro](https://community.appfarm.io/u/torstro)\
**Post date:** [January 17, 2023, 9:30am UTC](https://community.appfarm.io/t/tables-and-object-in-context-clarification/190/1 "2023-01-17T09:30:12Z")

</div>

Hello!

I have a project logging cars that drive into an area. I have a data source that is called Registerkontroll that log every entry with date and the car used. There is also a Bil data source that contains car objects. All Registerkontroll objects point to the Bil that drove in.

I have a table with Registerkontroll as the data source and would like to populate each row with the total number of entries for each car. I have tried with a function returning the length of the Registerkontroll array when filtered with the Bil in context. See my screenshot. But this is only returning the total number of Registerkontroll objects. What did I misunderstand here?

 ![image](https://europe1.discourse-cdn.com/flex013/uploads/appfarm/original/1X/d276c030fe444f6459040fc0620618673a399eed.png)

---

<div class="post-metadata">

**Author:** ![Olav](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/olav/32/63_2.png) [@Olav](https://community.appfarm.io/u/Olav)\
**Post date:** [January 17, 2023, 2:35pm UTC](https://community.appfarm.io/t/tables-and-object-in-context-clarification/190/2 "2023-01-17T14:35:36Z")

</div>

Hi!

If you want each row to have the total number of entries for each car, wouldn’t you instead have Bil as the data source for your table? Then you could do the same as you have here, only with Registerkontroll.Bil EQUALS Bil (Context/Selected) in the filter.

---

<div class="post-metadata">

**Author:** ![torstro](https://avatars.discourse-cdn.com/v4/letter/t/5daacb/32.png) [@torstro](https://community.appfarm.io/u/torstro)\
**Post date:** [January 18, 2023, 8:05am UTC](https://community.appfarm.io/t/tables-and-object-in-context-clarification/190/3 "2023-01-18T08:05:52Z")

</div>

The purpose of the table is to show entries sorted by entry time and the same car can enter multiple times per day. So it doesn’t really make sense to use Bil as a data source in this table.

If it’s not possible to do something like this I’ll make a second table with most frequent visitors with Bil as a source. 🙂

---

<div class="post-metadata">

**Author:** ![Olav](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/olav/32/63_2.png) [@Olav](https://community.appfarm.io/u/Olav)\
**Post date:** [January 18, 2023, 9:36am UTC](https://community.appfarm.io/t/tables-and-object-in-context-clarification/190/4 "2023-01-18T09:36:16Z")

</div>

Your setup looks correct, and I tried to recreate it in a different solution and got the same result, where it shows the total number of objects in the data source instead of the filtered number.

However, I tried to do the same thing, just using JS in the function editor, and that gave the expected result, so you can try the following:  
return registerkontroll.filter(registerkontroll =\> registerkontroll.bil === id).length  
Where “id” is the parameter Registerkontroll.Bil.ID

We will investigate why the filter on the data source did not work as expected.

---

<div class="post-metadata">

**Author:** ![Olav](https://dub1.discourse-cdn.com/flex013/user_avatar/community.appfarm.io/olav/32/63_2.png) [@Olav](https://community.appfarm.io/u/Olav)\
**Post date:** [January 19, 2023, 7:45am UTC](https://community.appfarm.io/t/tables-and-object-in-context-clarification/190/5 "2023-01-19T07:45:00Z")

</div>

Challenge registered on this one.  
Your setup should have worked, so we will solve that. For now, the workaround indicated above is the way to go.

---

<div class="post-metadata">

**Author:** ![torstro](https://avatars.discourse-cdn.com/v4/letter/t/5daacb/32.png) [@torstro](https://community.appfarm.io/u/torstro)\
**Post date:** [January 19, 2023, 7:56am UTC](https://community.appfarm.io/t/tables-and-object-in-context-clarification/190/6 "2023-01-19T07:56:43Z")

</div>

Thank you. I started to doubt everything I knew about appfarm for a minute there 😃
