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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

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

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

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.