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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Using Randbetween for a column level condition

I want to assign random values between 1 to 30 for a particular category "C" alone,means all other categories will have a value of 0.

How can I achieve this?

randnum = if('Y[Categ]="C",rand(),0),this is my current calculated column,I have values between  0 and 1 returning,but I want values between 1 & 30 returning when the Categ is "C".
 
1 ACCEPTED SOLUTION

What error message are you getting?

 

Otherwise if Randbetween is not working you could use something like

 

Column = IF('Table'[Categ] = "C",RAND()*(30-1)+1,0)

 

 

View solution in original post

3 REPLIES 3
Gordonlilj
Solution Sage
Solution Sage

Hi,

 

Is this what you're after?

Column = IF('Table'[Categ] = "C",RANDBETWEEN(1,30),0)

 

Anonymous
Not applicable

I tried doing that but getting an error.Thanks for responding.

What error message are you getting?

 

Otherwise if Randbetween is not working you could use something like

 

Column = IF('Table'[Categ] = "C",RAND()*(30-1)+1,0)

 

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.