Tables and Object in context clarification


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?


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.

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. :slight_smile:

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.

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.

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