Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

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".
 
  • 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)

     

     

3 Replies

  • Hi,

     

    Is this what you're after?

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

     

    • Anonymous's avatar
      Anonymous
      Not applicable

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

      • Gordonlilj's avatar
        Gordonlilj
        Solution Sage

        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)