Skip to main content

Get percentage

Hi,
I need to do a calcul to get a result in percentage % , so is there any function or script to do it ?
as alternative solution what I'm doing is : creating new numeric field and I insert this fomule : (Column A / Column B )*100  
Thank you.

Brian Element Tue, 10/24/2017 - 07:36

Hi Ahmed,

I would just do it the way you said, create a virtual field with that formula.  You can easily incorporate it into a script if you want.

Thanks

Brian

Ahmed Tue, 10/24/2017 - 09:09

Hi Brian;
I found also this; but with character type :  @Insert(@Str(( (A /B) * 100 );0;2);6 ; "%") 
As you can see it in the snapshot,
Thank you Brian.
 

Brian Element Tue, 10/24/2017 - 09:14

Hi Ahmed,

I would probably change your equation if you expect to have negative percentages or over 100% as the % is being inserted in position 6 so it is possible that it might get inserted before the last number.  I would use:

(@Str(( (A /B) * 100 );0;2) + "%"

This way you are always sure that the last character is the percentage.

Ahmed Tue, 10/24/2017 - 10:44

Yes Bian, it's more accurate.
and if I want to convert it to numeric field is there any equation to do it ?
Thank you.

Brian Element Tue, 10/24/2017 - 11:06

Hi Ahmed, if you want to convert it to numeric you need to first either not add or remove the % and then use the @val() function.  That will take a string and change it to a number.