Forum Academy Marketplace Showcase Pricing Features

Counting items in a data type

I have been stuck on this problem for a few days and i need some help please:

I am building a recipe book app where you can add your own recipes and bookmark the ones of others, growing your ‘recipe book’ with both your own and other’s recipes.

I am trying to display a view kind of like an ‘index’ page of a recipe book with all the categories (beef, poultry, kids, vegan etc) and the number of recipes and bookmarks the specific page user has in that category. I’m displaying it in the format [category name] (‘x’ + ‘y’) where x is the users’ own recipes and y is bookmarked recipes (e.g. “Starters (1 + 2)”, where this user created 1 recipe with a category ‘Starter’ and 2 bookmarks of others’ recipes of category ‘Starter’).

Bit of background:

  • Recipe is a Data Type with a few fields, but importantly it has a ‘category’ field of type RecipeCategory and this is a ‘list of things’ type field (this is probably why this is so difficult).It also has a ‘owner’ field to which the current user is compared to see if it is the recipe of that user or not (i know i could have used the ‘creator’ field, but since you cannot change the creator field, this gave me that option to change the owner).
  • RecipeCategory is a Data Type with only 1 field, ‘name’. the categories gets saved in the Recipe table under Category (list of things type as previously mentioned)
    -Bookmark is a Data Type with a ‘recipe’ and ‘user’ field, simply matching the bookmarked recipe to the user. I guess i also could have added a ‘bookmarks’ field to the user and marked ‘list of things’, but i like this more.

My layout is as follows: in a repeating group of Type RecipeCategory , i have a text field with:
Parent group’s RecipeCategory’s name “(“Search for Recipes:count” + “Search for Bookmark:count”)” - notice i marked all 'white text items in “”.
The first count was easy: “Search for Recipes:count” with constraints on the Search for type Recipes on ‘category contains Parent group’s RecipeCategory’ and ‘owner = Current User’. Works like a charm.
The second one is the problem. What i got so far is: ‘Search for Bookmarks:count’ with constraints on the Search for Bookmarks on ‘user = Current User’ and ‘recipe = Search for Recipes:first’ item where i have a constraint on this nested search on ‘category contains Parent group’s RecipeCategory’.
I am pretty sure the problem is with that ‘first item’ as i am not at all sure what to select there, that was one of the few options that did not give me an error.

I know this might be alot to ask to resolve without a working example or even screenshots, if at all possible please give me some pointers. Since my app is closed at the moment, i will duplicate this in an public app during today and i will post it here in a few hours. But if someone has done something like this in the past help would be MUCH appreciated.

I suspect you will need to do a :filter instead of a constraint.

So constraint the bookmark on = Current User

And then add a filter, and then choose Advanced…


THIS WORKED PERFECTLY!!! i owe you a beer, i will be in touch.

Because i used a ‘list of things’ as a field, it was slightly different (screenshot below), but i NEVER would have thought to use this advanced filter feature, i can only image the power it will give me in my other views!!! AMAZING.