如何在Tableau中生成伪随机数和行数 [英] how to generate pseudo random numbers and row-count in Tableau
问题描述
如何在Tableau中生成伪随机数和行数?我没有找到任何内置函数(例如"RAND","RCOUNT").
How to generate pseudo random numbers and row-counts in Tableau? I didn't find any built-in functions (like 'RAND', 'RCOUNT').
推荐答案
刚刚了解到Tableau中有一个Random()
函数.它不在库中,但是如果您仍然使用它,它将告诉您该公式有效,并创建一个介于0和1之间的值.
Just learned that there is a Random()
function in Tableau. It is not in the library but if you use it anyway, it will tell you that the formula is valid and create a value between 0 and 1.
要使用受官方支持的功能的原始且仍然有效的答案:
由于Tableau用于根据数据创建图形,因此随机数通常很少使用(您能解释一下它们的用途吗?)
Since Tableau is used to create graphs based on your data, there is usually little use for random numbers (would you explain what you need them for?)
不过,您可以使用这种方法来解决此限制: http://community. tableau.com/docs/DOC-1474
However you could use an approach like this to work around this limitation: http://community.tableau.com/docs/DOC-1474
基本上没有时间获取半随机种子,根据表计算将其与其他值组合,然后将其与其他半随机值相乘
Basically getting a semi-random seed out of the time, combine it with other values based on table calculations and multiplying it with 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 the result.
这篇关于如何在Tableau中生成伪随机数和行数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!