Forum Academy Marketplace Showcase Pricing Features

Creating a field which can only be one of two/three things

Hello,

I have a data type Client. I want to identify if this Client is either -

  1. Paying
  2. Probono

I considered adding a field in the data type Client which would be “client type”, but then do I need to create a completely new data type called Client Type and add two entries that are (Paying + Probono), or is there a better implementation?

I thought about adding a boolean field and call it “paying” but then what if I later on need more than just the two, and I’m also worried about this being confusing for the users or if it might be less easy to work with later on.

I also considered creating a field “client type” that is of the type “text” and just limit the user those two choices when selecting the client type - Probono/Paying - using a dropdown with static options. Not sure if that’s the best implementation though and if it would allow me to filter and search between those two client types .

Any thoughts? Thanks in advance!

If something can only be one of two things, this is a Boolean (“yes/no” in Bubble terminology). And you define the field by one thing being in opposition to the other.

So a Client is either:

  • Paying no / Paying yes … or…
  • Probono no / Probono yes

… depending upon which you think is more common. So you set up a Client like so:

  1. Either a Client has a field called “Paying” (a yes/no) … or…
  2. A Client has a field called “Probono” (a yes/no)

More about Booleans: Video: Working with Booleans (yes/no values) in Bubble - Are YOU Cool with Boole?

Thanks @keith. However, if it’s a boolean, how do I work with it? I was trying to create a pie chart using Bubble’s chart element that shows how many of the clients are paying vs probono, but I couldn’t figure out how to make it using the field as a boolean. Is it doable?

There’s an example below - I’m not sure what needs to be added into data source and value expression.

Hi there, @mohamed1… I’m not trying to confuse the matter because using a Boolean is certainly a way to go, and you called that out yourself in the original post. However, I would go a different route because of this part of your original message…

Yup, that’s exactly what I was thinking when I read your post, and because of that statement, I would use an option set (as opposed to a new data type) to define the possible client types. Then, create a Type field (or whatever you want to call it) in the Client data type, and set the Field type of that field to the option set, and the rest should flow from there.

Again, there is nothing wrong with using a Boolean if it meets your needs, but I wanted to throw this suggestion out there as food for thought.

Hope this helps.

Best…
Mike

2 Likes

Thanks @mikeloc!

Do you have an answer in regards to the question I asked afterward, about the chart?

I was trying to create a pie chart using Bubble’s chart element that shows how many of the clients are paying vs probono, but I couldn’t figure out how to make it using the field as a boolean. Is it doable?

Thank you.

Sure, @mohamed1… if you go with the configuration I suggested, you could set up your chart like this…

Hope this helps.

Best…
Mike

1 Like

Thanks @mikeloc. How would I go at it if I have it as boolean?

Thanks.

To the best of my knowledge, you can’t group by a yes/no field, so the short answer is I don’t know without doing some work to try to figure it out. Honestly, though, if you think there is even the slightest chance you will want to add more client types in the future, you really should consider going down the option set path.

Best…
Mike

2 Likes