Finding the highest value

  • 17 November 2016
  • 8 replies
  • 2 views

Badge +2

Hi

I have a number of fields where users can choose from option A to E, with A being the highest value.  I need to find out what the highest value is that has been chosen out of any of these fields.

For example:

Field 1 value chosen B

Field 2 value chosen E

Field 3 value chosen A

The highest value is A, which is in field 3.

Field 1 value chosen C

Field 2 value chosen B

Field 3 value hosen D

The highest value is B, which is in field 2

Is it possible to get these fields into an array or set of value that I can sort and then pick the highest or something.  Any help is highly appreciated happy.png.

Thanks


8 replies

Badge +16

is this in workflow?  you can use the collection operation action to add these fields into the collection and then sort etc

Badge +2

Sorry, this is in a form.

Userlevel 5
Badge +14

within the form you could do it eg. following way.

place a calculated control on the form and set its formula following way.

f1-f4 are named controls which 'highest value' is evaluated

String.fromCharCode(min([f1.charCodeAt(0),f2.charCodeAt(0),f3.charCodeAt(0),f4.charCodeAt(0)]))

it's little tricky but hopefully you will  manage to get it working.

Badge +2

That's an awesome solution, thanks Marian.  Great to know also that it's possible to add JavaScript into a formula.  Is it possible to add multiple lines of JavaScript code?

Userlevel 5
Badge +14

to be honest, I've tried that before.

but why not happy.png

Badge +2

Great, thanks Marian

Badge +4

Hi Marian,

  1. I have a 5 of fields where users can choose from option (Incidental,Minor,Moderate,Major,Sereve) , with Sereve being the highest value.  I need to find out what the highest value is that has been chosen out of any of these fields.

 

For example:

Field 1 value chosen Incidental

Field 2 value chosen Minor

Field 3 value chosen Moderate

Field 4 value chosen Major

Field 5 value chosen Sereve

The highest value is Sereve, which is in field 5.

Field 1 value chosen Incidental

Field 2 value chosen Minor

Field 3 value chosen Moderate

Field 4 value chosen Major

Field 5 value chosen Incidental

The highest value is Major, which is in field 4

Field 1 value chosen Incidental

Field 2 value chosen Minor

Field 3 value chosen Incidental

Field 4 value chosen Incidental

Field 5 value chosen Incidental

The highest value is Minor, which is in field 2

  Any help is highly appreciated ?.

Userlevel 5
Badge +14

this seem to be completely different problem to the one discussed in this topic.

I'd suggest to start new question.

Reply