Evaluate ":count" as a List of Numbers

Hey folks,
I am having an issue with something that should be easy to do.
I want to have a list of numbers using the “: Count” expression on a list of Things which is a data field inside another Thing.

Here is an example:
Country (Thing):

  • name
  • area code
  • other info

Bollards (Thing):

  • name
  • color
  • shape
  • List of Countries

Now I have a state on my page called “List of Countries Count” which is a list of numbers and I would like to populate it with a list of the count of each bollard’s number of countries.
image

This’s my attempt:
image

What I was expecting:
I was expecting to have a list of numbers of each Bollard’s number of countries but for some reason the “:count” method is simply evaluating a number instead of a list of numbers!

So for example a White/Black/Yellow Bollard would have a list of let’s say UK, Isle of Man, and Australia and a White/Red Bollard would have Turkey and Romania. In that case, I would expect to have a list of [3, 2].

Any help would be appreciated!
Thanks

Have you enabled the parenthesis feature in Bubble? You can do so by going to Settings → Versions → scrolling down to the checkbox and selecting it.

Once you do that, you can accordingly format your expressions to give you a list of counts.

Let me know if you are able to work this out :slight_smile:

I enabled it a few mintues ago and couldn’t figure out what order of parantheses I need to acheive the results I want.
I also wasn’t able to put any parantheses in, I am not sure if it’s bugged.

Want to get on a quick call to figure this out?

I’ll check my schedule but I was hoping to fix it without call if it’s possible.

Why do you need this list of numbers? (I can’t see any logical use-case for that)…

What are you trying to do?

Hey Adam!
So it’s a bit complicated but this list of numbers actually saves me from checking conditiuons 49 times in a list of 128.

Basically, I have a data type of Bollards, Pooles, Lisence Plate Design, Flags, etc and I would like to have a repeating group that lists the info of each of these data types depending on the URL.

That would have been easy if the Content Type was dynamic then I would be able to check if a paramter from the URL is Bollards then I’d display the info of each Bollard in each cell in the reapting group.

So I figured the only solution is to:

  1. have a condition that checks the URL within each cell 49 times (since I have 49 data types to identify different countries) and repeat that for the title, image, and other info.
  2. or check the URL on page load and store the info lists from the start to use in the reapting group cells to save calulcations. That way I saved checking the conditon 18k times and now it’s just 49 times at the start.



@tahycoon

Try this expression:

This should give a list of counts which you can use to set the state.
Let me know if that works.

3 Likes

You can install the free toolbox plugin which has an element for list of numbers. Very easy and intuitive to use. You should be able to use the search:count as the number of items in the list.

I won’t pretend to understand any of that…

But @codefree is correct… the way to do this in Bubble is using the :Format as Text operator on the list of Bollards, getting the count of each Bollard’s Countries, then splitting the output text into a list of texts.

Of course, you’ll also need to then convert each text to a number in order to end up with a list of numbers.

1 Like

Hey sorry for the late response!

I think this got me very close to what I wanted to get. The only thing missing is with that expression I would get a singular text but I was wondering if it’s somehow possible to convert it to a list of numbers (or even texts)?

My state is a list of numbers but I think I can work with a list of texts with each element being the count of countries.

EDIT:
I found it:
image
Thank you everyone!

1 Like

Is this supposed to just generate a list of numbers of the same number? I tried this in an app as the approach was pretty novel and I like making use of plain vanilla functions.

The result I got was 119 numbers in the list all of which were 119. Did I do something wrong or is it expected that each number would be the same in the list and that number would be equal to the total count of that list?

Did you accidentally put the search expression inside of Format as text instead of This X’s List of Y?

Thanks for that. I was under the impression it was used to generate a list of numbers stemming from the original search entry count…I didn’t realize it is to find a list of numbers associated with a count of a list field belonging to each data entry.

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