How many items in a list belogning to a thing that match a condition

How do I count items in a list that meet a condition that are in a repeating group?

I have a repeating group that has all jobs. Each job has a list of tasks. I want to show a count of how many tasks each job has (works ok) and also how many are completed tasks (can’t get it to work).

Example:
Job one has 10 tasks 2 are completed
Job two has 12 tasks 4 are completed

I can get the total # of tasked but I am having a heck of time figuring out how to filter just the completed task that have in a is_completed (yes/no) field.

This part works:
This part gives me the number of tasks
I have Search Job’s Tasks: count (where search is type jobs and jobs ID = currents cell job’s unique ID

This part does not works:
However I can’t figure out how to filter the same results of tasks that are is_completed=yes

Any ideas?

Option 1:

Search Job’s Tasks :filtered This task’s is_completed is yes

Option 2:

Search for Tasks: count (constraints > is_completed is yes, job = current cell’s job)
Option 2 requires a job field under Task type.

In option 2 could you explain how I does the Job field is done in the task table.

I have been looking to do this initially. I thought there would be a field that automatically relates the task items to a job. Which is has been working great but it does this automatically. But when I try to filter only the tasks that belong to a job I can’t find a field to that links them.

From what you are saying I need to add this field, so do I add a field call associated_job and make job type but how does the job id get placed in there when i save the task?

If you create a field called associated_job that is a job type, whenever a task is created you’d set associated_job = job … selecting the job depends on how you have your page set up. Maybe it’s a parent group or the current page’s thing. But since Job ID is part of the job record, you don’t necessarily need to reference the ID specifically, just the job.

What if I try like this which works except I can’t figure out how to bring just the “is_completed”

Types Jobs
Contains a list of WorkOrderLive which I was referring as Task in the previous posts
WorkOrderLives have a field is_completed (yes/no)

This just give me the total number of tasks (WorkOrders) but can’t filter for is_complete.Uploading…

Before :count, add :filtered and there you can add the is_completed constraint… and then add :count

I have been doing that too and I get the total and not just the ones checked marked yes.

I have also attempted the “is yes”:count and I still get all the work order in a job.

I meant the expression should read:

Search for Job’s WorkOrdersLive :filtered (constraint: this workorderslive is_completed is yes) :count

(plus, obviously your unique id constraint on the “search for jobs” part)

Finally got it to work the following way. Very non-intuitive. Notice the very small difference with the previous image above. (take out the first constraint is not needed it is not relevant)

Several hours on this little simple thing… I love Bubble, but this one was not fun.

@romanmg Gaby always willing to help so much. These are my own projects but when I get a client that wants to use Bubble, I am sure going to look for your professional help.

2 Likes

This topic was automatically closed after 70 days. New replies are no longer allowed.