# Help with calculating user form inputs to create an output

Hi everyone,

Very new to Bumble and developing at this level in general. The most I’ve done is the far more basic site creation like Wix etc. This tool is amazing though and I’m creating an MVP for a web app.

I’m struggling to identify the correct method to take non-numeric database entries to generate a numeric output. Here’s a more specific example

Question 1 has 4 options (A.B,C,D) and each option is a qualitative statement
All further questions follow this format roughly with 10 total questions.

I’m trying to create an output based on all of the inputs the user entered. For example, if a user entered mostly ‘Option D’, then I’d like to recommend “Product D.” And I need to be relatively nuanced as in not binary from the answer to any one question.

The method I thought would be simplest was assigning a value to each answer choice (A=1, B=2, C=3, etc), summing all answer choices, taking the summed value and displaying an option based on the summed value. For example, if all answers sum to 30, then recommend “Product C”

I feel like I’m so close to figuring this out with setting ‘states’ but I just couldn’t get there. Appreciate any suggestions for how to go from a qualitative input and generate a quantitative output from the database.

have a group (group A) that you leave hidden somewhere on the page and set the data type of that group to be integer and the data source to be blank. Then when someone clicks D for example, display data in the group → group A’s number + 4 (whatever the valuye of D is) and keep doing that and then reference the group’s value to recommend the product

I think I’m following and thank you for your help! I have a few follow up questions.

Would I just assign a group to each answer choice? So for question 1 with 4 choices, instead of one radio button input with four options inside the element, I’d have four individual inputs each in their own group?

In this instance, would I be able to have the +4 calculated only when the form was submitted or every time someone clicked on a selection. For example, if a user first clicks A, then changes to B and submits the form - will both A and B’s value be calculated?

Oh then store the letter that they clicked in a custom state corresponding with the question and then when they click submit add the value to the group

Sorry, Struggling to understand how to do what you last suggested. I think I’m just too new to the Bubble functions but learning. Would you store the letter clicked in a custom state via a workflow?

Would I need to do individual elements for each answer choice or could I use one element with 4 choices inside the element? I couldn’t figure out how to set a state based on the answer chosen within a single radio button element that has four choices. Separate elements for each answer choice doesn’t seem to be the answer either because users would be able to select multiple and not every question should be multi select.

Appreciate the help and sorry for not getting it.

Don’t worry about it at all! Bubble definitely has a learning curve. Click on any element (preferably the group that houses the question and answer choices) and then at the very top of the popup that shows up, to the right, there is a little information icon which opens the element inspector. Then create a state called “answerchoice” or whatever you want to call it and make it a number field. Then, when the user clicks on any of the four answer choices (A,B,C,D) start a workflow and go to element actions, set state and select the object that you put the state on and then you should see “answerchoice” (the state that you made) and set that equal to whatever you want the value of that abswer choice to be. (like A is 1 point and B is 2, etc). Whenever a user changes their answer choice, they select A byt then click B instead, that state will change to reflect the most current selection because of this workflow as its essentially clearing the initial valye of the state and then changing it to whatever it should be based on the answer option. Let me know if this was the asnwer you were looking for or not.

1 Like

That did it! I didn’t realize I could just type in a value in the workflow expressions until I just tried it. Though when I have answers that are longer strings of text, it’s going to make for a long expression but I guess that is fine. Would like a cleaner way but I like this better than database calculations and calls (which is what I was trying to do).

I now have a counter that assigns values to each!

Thank you so much for clarifying the steps!

1 Like

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