How to generate pseudo random numbers and the number of rows in a table

How to generate pseudo-random numbers and counting rows in a table? I did not find any built-in functions (for example, "RAND", "RCOUNT").

+5
source share
1 answer

Edit: Just found out that there is a Random() function in the table. This is not in the library, but if you use it anyway, it will tell you that the formula is valid and creates a value from 0 to 1.

The original and still valid answer if you want to use officially supported features:

Since Tableau is used to create graphs based on your data, it is usually not enough to use them for random numbers (could you explain why you need them?)

However, you can use this approach to get around this limitation: http://community.tableau.com/docs/DOC-1474

Basically, getting a semi-random seed out of time, combine it with other values ​​based on tabular calculations and multiplying it by other semi-random values

 Seed (DATEPART('second', NOW()) + 1) * (DATEPART('minute', NOW()) + 1) * (DATEPART('hour', NOW()) + 1) * (DATEPART('day', NOW()) + 1) Random Number ((PREVIOUS_VALUE(MIN([Seed])) * 1140671485 + 12820163) % (2^24)) Random Int INT([Random Number] / (2^24) * [Random Upper Limit]) + 1 

Where [Random upper limit] is a user-defined value to limit the range of results.

+4
source

Source: https://habr.com/ru/post/1236600/


All Articles