Forum Discussion
Xostensial
Jun 01, 2024Copper Contributor
Need help excluding values from INDEX function
I'm a complete newbie to excel and am struggling to find a way to get a random row from B1 - B15 while excluding the rows with 0. It's important to note that I need this formula to be able to...
dscheikey
Jun 01, 2024Bronze Contributor
=IFERROR(INDEX(FILTER(B1:B15,B1:B15<>0),SORTBY(SEQUENCE(15),RANDARRAY(15))),"")
And without gaps:
=IFERROR(INDEX(FILTER(B1:B15,B1:B15<>0),SORTBY(SEQUENCE(COUNTIF(B1:B15,"<>0")),RANDARRAY(COUNTIF(B1:B15,"<>0")))),"")
That should work!
- XostensialJun 02, 2024Copper Contributor
dscheikey Didn't work exactly how I wanted it to, but to be fair I wasn't very precise with my wording, and your response helped me find a workaround! Thanks for your time!