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.
This’s my attempt:
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].
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.
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:
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.
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.
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.
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.
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.
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?
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.