Using % in if formula


I'm working on a snippet that will evaluate a % and assign a variable "status" based on that percentage:

Your 10-Year Risk: {formtext: name=Your 10-Year; default=%}
{if: Your 10-Year<5}{10-Year ASCVD Status="Optimal 10Y Risk"}{elseif: Your 10-Year>=5}{10-Year ASCVD Status="Elevated 10Y Risk"}{endif}

Is there a way to turn the Your 10-Year variable from a % to just the number (ie 5% to 5) so it can be used in the if formula? We need to input the % b/c we use it in other places.


@Abby_Buccino here's one way to do it:

Your 10-Year Risk: {formtext: name=Your 10-Year; default=7%}{numberonly=extractregex(`Your 10-Year`, "\d+")}
{if: numberonly<5}{`10-Year ASCVD Status`="Optimal 10Y Risk"}{elseif: numberonly>=5}{`10-Year ASCVD Status`="Elevated 10Y Risk"}{endif}
{=`10-Year ASCVD Status`}

Only number version of the text box above: {=numberonly}

I used regex to extract just the numbers entered into the text field, and called that numberonly. I then used number only in your if statement instead of the original box. The last line is just demonstrating that I'm getting only the number and isn't needed.

Note that I'm not amazing with regex so FYI my formula doesn't get any number after a decimal point if you use those (e.g. 7.95% comes out as "7").


This is exactly what I need. Thank you again :smile: