Forum Academy Marketplace Showcase Pricing Features

Struggling to change a single field in a list of things (E.g.Count how many time a color has been added to a car)

Hi all,

I am trying to build a review system, where a user can select words (tags) from a list, to review a place.
This part works quite well i think but i also want to count how many times a word has been added to a given place. For some reason, when I increment the count, it does it for all words to every places, not only the reviewed place… i must be missing something when playing with “make change to thing”.

I have reproduced an example in the forum app, trying to add color to a car (detailed instruction in the page):

Could anyone take a look and explain me what am doing wrong here?

Many thanks for your help
Sam

I had a look, and it isn’t quite clear what you are trying to achieve.

So … do you want to count the number of times the colour is tagged on the car, or the number of times that colour is tagged on any car.

I think the issue is with how Bubble’s database works.

If you have a thing “Ford” which has a field “List of Colours” of type “Colour”.

And you have a thing “Red” which is a data type “Colour”.

If you add “Red” to Ford’s list of colours … then it is the same “Red” if you then add it to any other car.

It doesn’t create a copy. So when you +1 on “Red” it is the same “Red” everywhere.

I changed up your structure to get what you need.

The Car data type just contains car name and nothing more.
The Color Tag data type (changed from Color1) contains:

  • Name (type text)
  • Car (type car)
  • In Use (type yes/no)
  • Count (type number)

When a new color tag is created, Name and In Use are set (text and no). Adding a color to a car from this same list will then CREATE a new color tag, this time with In Use = yes, Car = The Group’s Car & Count = 1. If this has already been created, it’ll +1 the count.

Like Nigel said, you need to have different tags for the different cars if you’re going to keep separate counts. So with this set up, a copy of the tag is created for each car that uses it (only once), and then every time after, the count goes up by 1. The In Use field is used to filter out the original tag list to choose from.

Study the new structure and see if you understand. Let me know if you have any questions.

I would probably be tempted to have both Car and Colour as Data Types, and then have a Tag thing that links both and includes the count, that gets rid of the “In Use” field and might make it a little easier.

Yeah, that’s a good idea. A 3rd Thing would allow everything to be cross-referenced.

Great thanks to both of you.

@NigelG I confirm i was interested in counting the number of times the color is tagged on THE car. So, with the modification made by Roman, it does work as expected.

My problem was indeed the data structure, despite i read your numerous messages about that in the forum :).
I will make some tests with a Thing Tag as you suggested in your last post.

@romanmg As said, that works great so thanks again for making the change. I understand what you have done, I am just not sure how “In use” is used? I can’t find it in the workflow or repeating group. Can you clarify what the purpose is?

Now I just need to make some test to see if this new structure allows me for instance, to filter/ sort the Car by color or color count.
For instance: Show all cars that are Red, ranked by the biggest count.

The way I set it up, whenever a tag is applied to a car, it actually creates a copy of the tag so that the count can remain separate, but it’s still type Color Tag, so I don’t want all copies to appear in the list of tag options, just 1 instance of each original tag. So, “In Use” is the field (in Color Tag type) used to distinguish whether it’s the original tag or a copy that connects it to a specific car. A simple yes/no field like that allows for lists to be filtered. You can see it in the repeating group source for your lists that show tags just added and tags available to add to each car.

What Nigel was saying was that the original colors be a separate data type from the tags that are created when applied to a car. You wouldn’t need to filter in the way I have set up, and it might benefit your database searches in other ways down the road. It really depends on your use case and what you plan to do from here. Cross-referencing items can be done in a variety of ways.

Yes, you can sort the way you described. For a repeating group source: Type Car > Do a search for Color Tag (constraint > name = red)'s Car & sort by the Count field > descending = yes

I added that RG to the example app (below your instructions). I used a dropdown to select the color, and upon selection, it will change the list. Study the dropdown source and the RG source. These involve no workflows; it’s purely how you search your database.

Hope this helps!

That helps a lot. As I want to have more tags (not only words) I will play a bit with it to see how far I can go. I have some ideas in mind, adding a category for instance to define the category of Tags when being created (Color, etc)

If I am stuck somewhere, I will post again and ask for some support.

Best,
Sam

1 Like

Hi Gaby,

I have updated it to reflect your suggestion to have the color as a separate data and it works just fine, and it is indeed simpler this way.

I have also changed the color and cars because it didn’t make much sense so now it’s about tags and country :slight_smile:

Now, I would need to add a few more stuffs when a user makes a review:

  • A rate (from 1 to 5) and compute the average
  • Data from the users making a reviews, like gender, age or nationality, to be stored and counted on the country

The whole point is to be able to do the following when displaying the results in a repeating group:

  • User will select a word (OK)
  • It will show the countries with the biggest counts of the selected word by ascending order (OK)
  • It would ideally need to sort the results taking into account the above criteria

For instance, if i am french, a male and am 28, and i click on adventure, I would like to see a list of country ideal for adventure, mostly appreciated by people my age, french and male.

I know it’s clearly not an easy question, but I would at least need to know if that is doable. 2 questions:

  1. Is the current structure adapted to store these data from the user and the rate? i guess not but i need to have them all under the same thing to sort them afterwards, right?

  2. Is there a kind of workaround to match criteria (a user and a list of things) like described above? i had in mind creating some kind of coefficient with weights to have an “algorithm” but i have no clue how it can be implemented…

Thanks for your help and keep up the great work with Coaching Bubble. I am open to a skype btw if you see a solution to that
Sam