# Random with Axure

Published on the 28 August 2015 Axure allows you to create and use variables in a pretty advanced way. I recently used the Math.random() function a lot, and thought it could be useful (at least for me) to write the good random formulas somewhere, for later reference. It is probably very easy for programmers, but this is not my case, and I don’t want to lose time trying to figure out which is the right way of writing the formulas each time. So here it is!

## Why do we need a random on Axure?

I have bee working on a lot of projects requiring data visualization lately. The simplest way to illustrate wireframes with data is to copy and paste. But then you have the same data and graphs repeated all over the pages, and at some point you lose the relevancy. Another solution is to manually change each occurrence, at least a bit to give the right feeling and not lose attention on repetition. Even if repeaters are a great tool for this, you still need to input the data manually at some point. As having the exact data is not what matters at this stage, I now use random as often as possible. It creates differences which give the right rythm to the page, without even having to bother about entering the data. This way I have only one master, set to randomly change on page load, and only one place to make updates if needed. ## The different random formulas I use

First of all, where is the random accessible in Axure? Every time you use an interaction like Move or Change size, you can by default enter a value. But on the right of the value field is a little “fx” icon. When you click on it, it opens a new window where you can program a custom value. From there, if you click on Insert variable or function, you can either use the variables you have previously created (but this is another topic) or use pre-defined functions, including the x and y positions, scroll, date, etc. In the Maths category is where you will find our Math-random().

1. When used as is, [[Math.random()]] returns a number (with a lot of decimals) between 0 and 1 (like 0.18444888074058946.) As-is, I didn’t find a useful application of the function, I must say.
2. You can easily change this number to get, for example, a percentage, with the following formula: [[Math.random() * 100]]. But in order to get rid of the decimals, you can use another function simulateously: [[Math.floor(Math.random() * 100)]]. This will return a plain number between 1 and 100.
3. If you need a number between precise boundaries (for example to set the size of a widget within a minimum and a maximum), you can add variables: [[Math.floor(Math.random() * (80 – 1))]] will return an integer between 0 and 80. If you need to exclude 0, [[Math.floor(Math.random() * (80 – 1) +1)]] will return an integer between 1 and 80.
4. To set a panel to a random state, I use numbers as states names (my panel has states 1, 2, 3, etc.), and use the function: [[Math.floor(Math.random() * (3 – 1) +1)]].
Tags :
{"ft_lang_label":"__label__en","ft_lang_prob":0.925693,"math_prob":0.91886103,"size":2000,"snap":"2022-05-2022-21","text_gpt3_token_len":430,"char_repetition_ratio":0.0996994,"word_repetition_ratio":0.0,"special_character_ratio":0.2135,"punctuation_ratio":0.103365384,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.9890892,"pos_list":[0,1,2,3,4,5,6],"im_url_duplicate_count":[null,8,null,4,null,8,null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2022-05-19T05:05:48Z\",\"WARC-Record-ID\":\"<urn:uuid:fbe1b3ac-882c-40bf-8601-4aca94ed5e4c>\",\"Content-Length\":\"52455\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:de0a142b-9e71-45cd-9661-d2379165f9be>\",\"WARC-Concurrent-To\":\"<urn:uuid:7c5a111f-32f3-43fc-b371-791a120b55e5>\",\"WARC-IP-Address\":\"188.165.14.151\",\"WARC-Target-URI\":\"http://www.mariekuter.com/random-with-axure\",\"WARC-Payload-Digest\":\"sha1:TF6MM7WV6EMWRCX6DOOIRTQ2LEUNB3A3\",\"WARC-Block-Digest\":\"sha1:QSX6DB2JJVB7LHDZFGJJQ45B53UEP2PF\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2022/CC-MAIN-2022-21/CC-MAIN-2022-21_segments_1652662525507.54_warc_CC-MAIN-20220519042059-20220519072059-00125.warc.gz\"}"}