Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
ahumke
Helper I
Helper I

RAND function how to randomly assign to groups

I'm trying to create a measure that will randomly assign people in my file to a treatment group or a control group if their score is above a threshold.  I've found the RAND command will generate a random number so I was thinking I could do a two step to assign groups.

 

Random Assignment = if ('Tuesday, July 7, 2020'[Weighted Average Score] > 3, RAND()*(2-1)+1)
Success Coach Assignment = if ('Tuesday, July 7, 2020'[Random Assignment] <1.50, "Yes")
 
This doesn't seem to be working though - each time I run the "Student Coach Assignment" field it seems to rerun the random assignment field - therby doing the Success Coach Assignment on the prior run values (meaning the assignment rule isn't followed) and the other problem is that once a person is assigned a value I don't want it to change for that person. The data will get updated and refreshed periodically to add people but the individual person should remain the same and I don't want their values to change at all.
 
Is there a way to make it work that way?
 
Thanks!
3 REPLIES 3
harshnathani
Community Champion
Community Champion

Hi @ahumke ,

 

You can try this 

 

Random Assignment =
IF (
    'Tuesday, July 7, 2020'[Weighted Average Score] > 3,
    DIVIDE (
        'Tuesday, July 7, 2020'[Weighted Average Score],
        100
    ) * ( 2 - 1 ) + 1
)

 


Regards,

Harsh Nathani


Appreciate with a Kudos!! (Click the Thumbs Up Button)

Did I answer your question? Mark my post as a solution!

 

amitchandak
Super User
Super User

@ahumke , Random function changes values with every load. You need to find a better way.

Maybe create a RANk and divide my max Rank +1

 

For Rank Refer these links
https://radacad.com/how-to-use-rankx-in-dax-part-2-of-3-calculated-measures
https://radacad.com/how-to-use-rankx-in-dax-part-1-of-3-calculated-columns
https://radacad.com/how-to-use-rankx-in-dax-part-3-of-3-the-finale
https://community.powerbi.com/t5/Community-Blog/Dynamic-TopN-made-easy-with-What-If-Parameter/ba-p/3...

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
edhans
Super User
Super User

Consider using List.Random inside of Power Query. It will only update on the refresh of the dataset, not as users are working in the report. Here is an article that shows how to do that



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.