Percentage Calculations and Currency Dollars and Cents (decimal places)
Apr 12, 2018
I am trying to do a simple 'percent of cost = waste' calculation, and it seems that I must do extra steps for this simple math. I have a percentage that is a decimal (33.4%), but cannot set the variable value to more than 2 significant digits after the decimal point (defaults to 0.33). The same occurs if I type in '33.4%' as the default value. I added an extra trigger to set the default value to 334 and another to divide by 1000. That seems to get the math correct, but the variable value still shows as 0.33. Then, the 'cost of waste' comes up with only one significant digit after the decimal point, where it should have 2 since it is currency. I am surprised that SL360 does not have percentage or currency as a variable type? Any suggestions to get this to show correctly. I think I saw one that was java script, but I need to stay away from that if possible. I've attached an example slide.
Thank you!
9 Replies
Storyline won't do it out of the box, 33.40 will always round to 33.4 on display.
this only real way is to do it in javascript and then output as a text variable
Thanks Phil. I'll see if I can find that example I saw before. I will put in a feature request as well.
Storyline example file
Phil, I was able to find the example (link to file above); copied the java script, changed the variable, added a text variable, and pasted it to a trigger. Works great now. Thanks again!
Michael,
I can't seem to get your link to work. Would you mind re-posting it so that I can look at it. I need to do the same thing.
Thanks!
Hi Matney,
I'm not sure if Michael is still subscribed here since this discussion is a bit older. You can connect with him using the Contact Me button on his profile to see what else he's able to share!
Hello Matney, that was a link I found to some JavaScript, not one that I created. It seems to have been taken down or moved. I will see if I can find it again, or maybe I can find what I copied and get it to you. Sorry for the slow reply, I was offline all weekend.
Matney, Here is a link to 2 sides of my course showing that it works (I had to make sure this was the one. https://360.articulate.com/review/content/00ebb2bf-bef4-4f87-b92c-36375e97e2f0/review . I have attached the SL360 file and a text file with the script that I added in the trigger on the second slide of the course (2 slides total to demonstrate it). I hope this is what you are looking for. I I recall correctly, the script converts the number to text to allow it to show with 2 significant digits after the decimal place. The variable that gets converted is one I call "costofwaste". It is converted to "costofwastetext". So, you have to create a new (text) variable so the script can set the value once converted.
Thank you so much for your help!! I am excited to look at this and see if
I can get it to work in my presentation!!
Thanks again,
Matney Jorgensen
Thanks, Michael for coming back to share with Matney!
This discussion is closed. You can start a new discussion or contact Articulate Support.