# Select Random Sample Values and Rows using Excel

In this video I help you solve the dual problems of selecting a random value from an Excel list and selecting a number of random rows from a range of data in Excel. At times when I am generating a data-set to use in my video tutorials, I want to select a random selection of rows. Typically, because my data values are clumped together and are too similar to the data on preceding and subsequent rows.

### SELECTING A RANDOM VALUE FROM A LIST

Enter three Excel formulas to save the day for selecting a random value from a list:

• ROWS()
• Returns the number of rows in a reference or array.
• RANDBETWEEN()
• Returns a random integer number between the numbers you specify. A new random integer number is returned every time the worksheet is calculated.
• INDEX()
• The INDEX function returns a value or the reference to a value from within a table or range.

1. In the screenshot above notice that the ROWS() function returns the value of 20, which corresponds to the number of names listed in the cell range of A6 to A25.
2. The RANDBETWEEN() function generated a random number between 1 and the value returned from ROWS() (i.e., 20). In this case, RANDBETWEEN() combined with ROWS() returned a value of 3.
3. By combining the results from the first 2 functions, the INDEX() function searches our list and returns the value of the 3rd cell in the listÂ  (i.e., Flor McCard) because the RANDBETWEEN() function returned a value of 3.

When we put it all together it looks like the following:

`=INDEX(\$A\$6:\$A\$25,RANDBETWEEN(1,ROWS(\$A\$6:\$A\$25)))`

I choose to use the absolute cell reference notation with dollar signs although in this case it is not necessary since we are not copying our results to other cells.

### SELECTING RANDOM ROWS FROM A LIST

We’ll only use 1 Excel formula to save the day for selecting random rows from a range:

• RAND()
• RAND() returns an evenly distributed random real number greater than or equal to 0 and less than 1. A new random real number is returned every time the worksheet is calculated.

By placing the RAND() function in a column co-located with your data, you will assign a random number to each row in your data-set or range.

Once that is done, all you have to do is sort your data by the RAND() column and then select however many rows you need. It’s that simple!

If you are like me, you probably need to see it in action to get a better understanding. Check out the video above and if you learned something, please go ahead and like it on my Youtube channel!

Thanks for your support!

All views and opinions are solely my own and do NOT necessarily reflect those of my employer.

References:

All Excel function definitions are from https://support.office.com

Advertisement

# Build a Tableau Parameter Action Dashboard

This video is inspired by Filippos Lymperopoulos who has a great article on parameter action concatenation. Definitely check out his article here. I am a hands on person who learns from building and sharing, therefore I put together this video to explore, tweak and hammer home the concept.

In this video we’ll build a Sales Analysis dashboard in Tableau using Parameter Actions and the Concatenation Aggregation functionality. The great thing about this tip is that you can use it across multiple data sources. This is a must see!

This approach relies upon the use of two different data connections. In this manner our data tables are completely un-joined without an established relationship. We have a data-set comprised of a customer list and one comprised of customer transactions across three years.

The key to linking the data sets together relies upon the following calculated field which creates a de-facto set that we can use to highlight customer purchases:

When we setup a concatenation parameter action on our dashboard, the very act of selecting a [Customer Name] will add that Customer Name to the parameter named [Selected Customer]. This will cause all selected customers to resolve to TRUE, which allows highlighting of the sales bar charts related to the user selected customers.

In the screenshot above, notice the selected [Customer Name] values on the left hand side are also concatenated together at the bottom of the dashboard (i.e., Franciso Hernandez, Jose Garcia, and Terrye Marchi). All of their respective purchases are also highlighted in the middle of the dashboard.

The above calculated field is used to only show the [QTY] purchased for the user selected customer and is placed on the bar chart label.

Feel free to interact with the viz and download the workbook on Tableau Public:

As always, If you find this type of instruction valuable make sure to subscribe to my YouTube channel.

All views and opinions are solely my own and do NOT necessarily reflect those of my employer.