How to calculate a percentage?

Hi there,
I’m trying to calculate a percentage of an amount - both the percentage and the amount are entered by the user. For example = $100 x 20% should equal $20. I’ve tried a few variations using multiplication but an not sure how to add the “1.” I’ve tried this [[Val * 1.(Rate)]] and this [[Val * 1.Rate]]. Then I noticed there’s a percentage function and tried this: [[Val * Rate%]] It still doesn’t work… Any ideas?

Hi!

20% of something is the same as 0.2 times something. So assuming Val is the local variable pointing to text of where the value is held, and Rate is the local variable holding where the percentage (e.g., 20) is held, your expression would be this:

[[Val * Rate / 100]]

This link explains local variables, if you are not already familiar.

Note that if the user is entering the percentage sign as well, you will need to strip that out.

[[ Val * Rate.replace("%", “”) / 100 ]]

That expression will work whether or not the percent sign is entered.

Thanks so much! It works perfectly with such an easy solution.