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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

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
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.