Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik Open Lakehouse is Now Generally Available! Discover the key highlights and partner resources here.
cancel
Showing results for 
Search instead for 
Did you mean: 
dcmcderm
Partner - Contributor III
Partner - Contributor III

When does rand() compute/update?

I'm building a demo app that is based on one of my customers actual data.  I need to "fudge" the numbers on a couple of charts so I'm not giving out real data from this customer during presentations.

I just multiplied the expression value by rand() which worked fine.  But my question is when does that function actually get computed when viewing over the AccessPoint?  Does it happen every time the document is opened?  On reload?  Only once ever?  I can't seem to figure it out.

Also if anybody has ideas about a better way to do this let me know.  I don't like the built in "scramble" feature because I need to have some control over the results so the data is somewhat realistic.

1 Solution

Accepted Solutions
swuehl
MVP
MVP

if you are talking about using RAND() in the frontend, i.e. in a chart expression, I think it's somehow bound to selection states, i.e. it changes when you make different selections, but same value for same selection state.

Something like this, AFAIR.

Edit: as mentioned above, reloading data will also reset your RAND() values

View solution in original post

6 Replies
sunny_talwar

For your first question: As far as I know it will be updated each time the application is reloaded.

Second question: I usuaully use AutoNumber() to anonymize data. Something like this:

'Part ' & AutoNumber([Part No.]) as [Part No.]

HirisH_V7
Master
Master

Hi,

Rand Function:

Rand() only returns a numbers between 0 and 1. You can use the result of rand to select from a list of numbers using various arithmetic and rounding operations. Some examples:

=ceil(rand()*1000,100)  ->It will Generate a number between 100 and 1000 in multiples of 100

=left(rand()*10,1)  -> Numbers 1 to 10


PFA,

Hirish

HirisH
swuehl
MVP
MVP

if you are talking about using RAND() in the frontend, i.e. in a chart expression, I think it's somehow bound to selection states, i.e. it changes when you make different selections, but same value for same selection state.

Something like this, AFAIR.

Edit: as mentioned above, reloading data will also reset your RAND() values

Peter_Cammaert
Partner - Champion III
Partner - Champion III

This is a difficult one. fumble with actual numbers will either make them fall out of an acceptable range, or won't change them enough to actually look different.

On the other hand, it's usually enough to obfuscate the identifying information instead of the amounts and quantities. If your demo document contains multiple customers/products/areas, just scramble or randomize the names and text strings in order to get just enough anonimity. .

dcmcderm
Partner - Contributor III
Partner - Contributor III
Author

Thanks, I tested this and you are right.  I created a text object that just displayed the result of the rand() function.  It changed every time I made a selection, but then changed back to it's previous value if I returned the document to its previous state.  And a reload seems to reset the value completely as well.

dcmcderm
Partner - Contributor III
Partner - Contributor III
Author

My customers are very non-tech savvy and I've found that if I scramble the names of actual entities (mine are names of health care providers, cities, clinical terminology etc.) they can't "make the leap" to put what I'm showing them into context.

What I've done is use my existing customers production data but have all charts report a value between 75% and 125% of the "actual" value.  That way all the text is intact, the values are believable in a real world scenario since they are still in the same ballpark, and the customers real/accurate performance data can't be gathered from it.