I have a number of columns that store boolean values based on some arbitrary stat tracking. As an example, they may store yes if you have a red jumper, or no if you do not.
I can plug this into a progress bar easily enough, but I want to store progress as an integer in another column, so I can trigger other elements to change without having to check every column, then resolve it as a boolean value.
I just want when [Red Jumper] = “yes” to + 1 and when [Red Jumper] = “no” to -1 from a sum column. This same logic will be applied to multiple columns.
Is there a simpler way to do it than writing two workflows per column?
A few ways of going about it, and I don’t know your specific use case but I’ll describe a simple extrovert/introvert quiz example. Let’s call 1 extrovert and -1 introvert. The user’s score is the average of their answers. We have a bunch of predictable questions with yes/no answers.
Question
content (text) - the content of the question
multiplier (number) - describes the direction of the answer, and its value. A multiplier of 1 will mean when the question is answered, the ‘score’ is 1. Multiplier of 2 means the score when yes will be 2. So, we use a positive multiplier when the yes answer should mean ‘extrovert’. Inversely, we use a negative multiplier when the yes answer should push the user’s score towards introvert.
Response
User (User) - the User who responded
Question (Question) - the Question they’re responding to
Answer (yes/no) - now, the obvious thing to do here is to put the score in the Response data type but I don’t think that aligns with your use case.
So, how do we search for the user’s answers, and get an integer from their responses?
Do a search for Response:format as text
This Response’s Answer formatted as number * This Response’s Question’s multiplier
Delimiter: ,
This returns a comma separated text with each response’s score. To get a total score, :split by , :each item converted to number:average
I appreciate that’s a long winded answer, but as I don’t really understand your exact example, this should send you in the right direction.
Thank you for jumping in on this one! I think I may have been too complex with my question so I’m going to try and make it clearer.
Imagine we have 4 columns: Red, Blue, Green, Yellow
Each of those columns holds a boolean value, yes/no
What I want to achieve is something like this:
IF(Red = yes, 1, 0)
IF(Blue = yes, 1, 0) and so on…
Then in a 5th column, I want to sum those values. So if Red and Blue are “yes” but the others are “no” the value of column 5 would be 2 of a possible 4.
However, if Red is changed to “no” then the sum column value should decrease to 1.
:format as number will do this part (1 for yes, 0 for no) - maybe you’ve already worked this out.
For your 5th column (the total), have a group we’ll call var - sum and a text inside var - sum. The group should be of type number. The data source of the group should be Red:formatted as number + Blue:formatted as number etc. You probably have the booleans for is red / is blue saved as custom states somewhere.
This means that whenever the red/blue changes, the number is always kept up to date. To display it, the text inside var - sum can be ‘Parent group’s number’.
Now, if you want to do something whenever the number changes, there’s not a dead simple way to ‘watch’ the group for the value change, but you can trigger a custom event from an input when it is changed. So, create a custom event that’s called something like ‘inputchanged’ and trigger it any time any input is changed. The custom event can do whatever you need to do when the sum changes.
You’re absolutely correct, this is how I created my progress bar, but realised I wanted to use the 5th column value as a reference for other parts of the app so I didn’t have to use that massive expression every time.
Essentially, I’m using this for checking a persons progress through a process. Once all columns = yes, then they can be considered complete.
I attempted to get the toggle (that’s what I’m using for the yes/no in the UI) to +/- 1 when they were “yes” but I got some crazy values. 0, then 3, then 14. Not sure what was going on there.
This was the method I attempted first. One workflow adds when the Toggle is no, one subtracts when the toggle is yes. The workflow is triggered when the Toggle is changed.
Is there a reason why bubble detects more than one input on a toggle?
Create a group called var - sum of type number like I said. The data source should be Input 1 is not empty:format as number + Input 2 is not empty:format as number + etc etc. No workflows are needed.