Loading

Random sampling implementation

Date de publication: Feb 28, 2025
Tâche

Random sampling implementation in Tableau. Example: Random sampling top 0-9 random customers from the data set

 

Étapes
1. Create a calculation for Random number generation

Option 1:
Use RANDOM() function:
RANDOM() Function Produces Inconsistent Results

Option 2 :
Use Tabpy

Random function implementation for 0-9 :
SCRIPT_INT("import random
return random.randint(0,9)",SUM([Sales]))

2. Create another filter calculation  INDEX()<[Random function implementation for 0-9]

3. Put Customer name on Rows and Drag filter calculation above to Filters and select True

Every time the sheet is refreshed or the data source is, it will produce random 0-9 customers.
Ressources supplémentaires
Analytics extensions need to be enabled in order to use the sample workbook attached.
Pass Expressions with Analytics Extensions
 
Numéro d’article de la base de connaissances

001456765

Pièces jointes

random_sampling.twbx

2370 KB

 
Chargement
Salesforce Help | Article