cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RoMario
Frequent Visitor

The best way to get random data from a table

I have a list with 532 rows. Those rows are splitted by months (like 200 rows as January, 200 rows as February and 132 rows as March).

 

What is the best way to add column with unique random number between 1 and 532?

I tried 

Random = RANDBETWEEN( 1 , COUNTROWS(NETWORK_ORDER) )

But it generates duplicates.

 

What I want to achieve is to be able to randomly select 50 rows from each month.

I thought to generate this unique random value and them apply some filters.

 

What do you think?

 

 

1 REPLY 1
Thejeswar
Super User
Super User

Hi ,

You may try to use the INDEX column to get unique numbers.

 

Below is something that I came across in a blog. You can try doing it this way to get unique Random values.

 

In DAX, you can use RAND() function  to generate random numbers. Similarly, to generate random numbers between two numbers, use  RANDBETWEEN().

In Power Query, List.Random() creates a list of random numbers, while Number.Random() creates a single random number. You can add an index column before using the Number.Random() to get different random numbers on each row. You can delete the index column after the Number.Random() step. There isn't a List.RandomBetween() but Number.RandomBetween() can be used along with index column to generate numbers between two specified values.

 

Regards,

 

Helpful resources

Announcements
November 2022 Update

Check it Out!

Click here to read more about the November 2022 updates!

Difinity Conference

Difinity Conference 2022

Difinity is the largest Microsoft Data, AI, Power BI, Power Platform and Business Applications Conference in New Zealand.

European Share Point Conference

European Share Point Conference

This conference returns live and in-person in Copenhagen this 28 November-01 December with 4 Microsoft Keynotes, 9 Tutorials, and 120 Sessions.

Microsoft 365 Conference â__ December 6-8, 2022

Microsoft 365 Conference - 06-08 December

Join us in Las Vegas to experience community, incredible learning opportunities, and connections that will help grow skills, know-how, and more.