Forum Discussion
Create column with random values from list
- 9 years ago
Anonymous
Please create a Rank column which display the location of text cell.
Rank = RANKX(Table1,Table1[Name],,ASC)
Then, we select any location according the random number between 1 to the max location. Use LOOKUPVALUE function grab the values.New Column = LOOKUPVALUE(Table1[Name],Table1[Rank],RANDBETWEEN(1,MAX(Table1[Rank])))
Please refer to the following screenshot.
Best Regards,
Angelia
Sounds like you are talking "M" Power Query language. If that is the case, you could use:
Number.Random
https://msdn.microsoft.com/en-us/library/mt253346.aspx
or
Number.RandomBetween:
https://msdn.microsoft.com/en-us/library/mt253327.aspx
If you want to do it in DAX, the only thing I can think of would be Sample:
https://msdn.microsoft.com/en-us/library/mt163692.aspx
@smoupre wrote:Number.Random
or
Number.RandomBetween:
Hi, thanks for your reply but I was looking for solutions for text values.
- tringuyenminh929 years agoMemorable MemberSame as we create sample data in excel, u just create one master table with 2 Column(id,text) and in fact table you add one column as reference column by random in range of id column of table master. After that make the relationship between 2 table.
- Greg_Deckler9 years agoCommunity Champion
OK, I guess I thought you'd get where I was going with that. Use the random number to retrieve that item from the list. For example, let's say that your list is has five items in it, and you call it "MyList", you could do something like:
MyList{Number.RandomBetween(0,4)}List positions start at 0, you can reference a specific list position by using the syntax: Listname{#}