Feedback
Answered

Comparing variables to get the variable with the highest number

  • 15 December 2021
  • 13 replies
  • 436 views

Badge

Hello,

I am building a form where a number is assigned to a variable upon choosing any answer. The sad thing is that i cannot compare variables to achieve knowing which variable has the largest number.

I need help asap.

Thank you

icon

Best answer by john.desborough 17 December 2021, 15:03

View original

13 replies

Userlevel 7
Badge +5

Hi @popekabu Welcome to the community! Happy to have you here. :sunglasses: Technically, you can’t compare variables, but you could possibly attempt this with a workaround. 

Could you tell us more about how you have your form built and how you’d like to compare the variables? 

Badge

First of all, thank you @Liz for reaching out.

My form is built in the sense that every answer selected in each screen will give a point to a specific variable declared in the form already.

I have 10 variables and at the end of form, i want to compare all the variables and find out which has the largest and based on that a screen will appear.

How do i make the comparisons please?

Userlevel 7
Badge +5

Hi @popekabu Got it - thank you! I asked our support team about this in case they had any fancy workarounds, and they mentioned the following: 

One way to compare variables would be to substract them and see if the result is bigger than 0 or not.
For instance diffSet1And2 = scoreSet1 - scoreSet2 if diffeSet1And2 > 0 it means that scoreSet1 > scoreSet2

 

I don’t know if this helps a bit, but hopefully it inspires some ideas!

Userlevel 7
Badge +6

@Liz - this thread also has the details in it.. where @popekabu also posted the same question. 

there are other threads in this Community who have the same topic where advice and answers are provided. 

des

Badge

Dear @Liz @Leslie , thank you unfortunately this will best work for two variables, am comparing 10 variables.  

Userlevel 7
Badge +6

@popekabu - use a little common sense: you need to extend the logic out to every combination possible and do the evaluation. In the other thread, i posted a grid that showed you a 12 variable evaluation framework. You just need to use that and map the variable names that I showed to what yours are and then do the logic. 

I’ve done this for over a dozen clients using this same framework. You just need to do the work to compare all the possible combinations. 

 

Badge

Thanks @john.desborough. I weighed all of that and decided to build the project with a web framework using codes so that I can have full control. Wish I saw this limitation earllier before paying for Premium. Thank you for you time. Typeform needs to advance a bit though. @Liz Youre amazing. Thank you

Userlevel 7
Badge +5

Glad to hear you were able to find a solution that worked for you, @popekabu ! Let us know if we can help with anything else. :grinning:

Badge

thank you @Liz 

Hello,

Can I have to link to the thread you mentionned where you compared 12 variables ? @john.desborough @Liz 

Kind regards

Userlevel 7
Badge +6

Hello,

Can I have to link to the thread you mentionned where you compared 12 variables ? @john.desborough @Liz 

Kind regards

@Mlanie - i don’t keep track of the links to the threads in which i post here, sorry. you will have to use the search function at the top of the page to try and find it (that’s the same thing i would have to do)

 

des

Hi all, thanks for your contributions.

I have only a doubt still on this intricated topic, and I would appreciate your support to make this ideas land.

The necessity to consider all the different combinations of the variables is clear, but how to then do it in practice in typeform? There is no place that I could find exploring the UI, on the guides or on the community that would allow to create lines of code like the one that Liz added in pink.

 

Thank you!

 

 

Hi @popekabu Got it - thank you! I asked our support team about this in case they had any fancy workarounds, and they mentioned the following: 

One way to compare variables would be to substract them and see if the result is bigger than 0 or not.
For instance diffSet1And2 = scoreSet1 - scoreSet2 if diffeSet1And2 > 0 it means that scoreSet1 > scoreSet2

 

I don’t know if this helps a bit, but hopefully it inspires some ideas!

 

Userlevel 7
Badge +6

@Made - you would put that in a series of logic rules: 

  • If scoreset1 GTE 0 then add scoreset1 to diffset1and2
  • if scoreset2 GTE q then subtract scoreset2 from diffset1and2
  • if diffset1and2 GT 0 then go to qX/ending A (an example) 
  • if diffset1and2 LTE 0 then go to qY/ending B 

 

des

Reply