Appling Rule to Percentage field not working

  • 18 January 2017
  • 3 replies
  • 5 views

Badge +1

Hi

In my list is a number field formated as %. Request has been made to apply a background color to the form field if the value is above a certain %. Applying a formatting rule should do the trick. Condition: [field]>[number]. It does work for fields not formatted as percentage. But I can't get it to work for % fields. While in edit mode the value is apparently only recognized as number and the color displays. When saved and in view mode, the rule is not applying.

Any suggestion to get around this?

Thanks!


3 replies

Userlevel 5
Badge +14

there are two problems with percentage fields

- they come in into form including percentage

- they are formatted with decimal separator (if configured to include decimals) acc. current user's locale which might mean decimal separator is not a dot

they both prevent onverting percentage value into a number and perform numeric comparison

I ended up using formula like this for comparisons

replace(replace({Self},"%",""),NWF.FormFiller.Functions.DecimalSymbol,".") > [number]
Badge +1

Hi Marian

Thanks for your reply. Your solution is surely a help if you want to do further calculations with the figure.

I got it working this morning by applying 2 different rules

- one for Edit mode where the figure is still recognized as a number only: [field] >90. This rule helps to color the figure already while filling the form.

- one for View mode where the figure seems to be treated more like text: [field] >"90 %".

Userlevel 5
Badge +14

my above formula works in both modes, so you do not need two rules happy.png

I would be careful with comparing texts!

- percent sign need not always be formatted the same way, eg. sometimes there is a space between the sign and number like in your case, sometimes not

- when comparing strings, "9 %" is greater then "50 %"

Reply