Home > Software design >  Excel & GoogleSheets - Randbetween with condition
Excel & GoogleSheets - Randbetween with condition

Time:12-14

I have a table with entered numbers (A:A) and specific dates (B:B). How could I randomly choose between entered number for each specific date?

In attached example, F2 should be random value between each number in A:A where B:B = 13.12.2022

enter image description here

I've tried playing with index and randbetween, but no result. I need formula for both Excel and Google Sheets.

Update: for Excel these do the trick

=INDEX($A$1:$A$30;INDEX(LARGE(($B$1:$B$30=D2)*ROW($A$1:$A$30);ROW($A$1:$A$30));1 INT(RAND()*COUNTIF($B$1:$B$30;D2))))

=MAP(D2:D4,LAMBDA(a,LET(x,FILTER(A2:A11,B2:B11=a),@SORTBY(x,RANDARRAY(COUNT(x))))))

But this doesnt work for Google Sheets.

CodePudding user response:

One option, try:

enter image description here

Formula in E2:

=MAP(D2:D4,LAMBDA(a,INDEX(FILTER(A2:A11,B2:B11=a),RANDBETWEEN(1,COUNTIF(B:B,a)))))
  • Related