基于Excel中的真实过滤器从列表中随机选择多个值

发布于 2025-02-05 12:41:58 字数 1752 浏览 2 评论 0原文

总结,

我想从Excel中的列表中选择多个随机选择的选项,但被过滤到仅包含另一列中具有真实指示器的选项。需要进行随机选择的数量需要变化。此外,不应拉动重复项。理想情况下,我想将一个公式包含在一个单元格中,如果可以的话,它会溢出到所需的长度。

当前尝试

通过= index= randbetweeen = filter和helper = rand的合并,我尝试通过= index = randbetweeen进行此逻辑工作。 ()列,试图过滤数据,然后从中随机选择。我发现的问题是= filter不喜欢正确组合(尽管我可能做错了什么)。此外,这涉及将公式复制到我想要一个随机选择的新选项的每个单元格中,如果可能的话,这是不理想的。

所需的输出

IDt/f数字的示例要随机选择?输出
1true52 [公式在这里并溢出]
2true5
3false7
4false 9 false5
true912
6false
7true
true 89 true
9true
10false 11 true
12true 12 true
12true

这是一个示例,说明了我如何理想地喜欢数据的输出。数据本身在a1:b13中。我将输入在c2中随机选择的选项数,然后将基于d2中包含的解决方案生成输出,该解决方案会相应地溢出。它仅从A列中的ID总体中选择的要求,其中true/false来自该ID的B列的指示器是true。我正在寻找解决这个问题的解决方案,是我需要放入d2的公式。

我一直希望改进的额外细节

,因此总是对某些事情的工作方式进行任何解释,因此我最终不会再问同样的事情了!

我正在使用MSO 365,但由于推出时间表,我仅限于版本2108

感谢您的任何帮助!

Summary

I would like to select multiple randomly selected options from a list within Excel, but filtered to only include those with a TRUE indicator in another column. The number of random selections to make will need to be vary. Additionally, duplicates shouldn't be pulled. Ideally, I would like to have the formula contained within one cell, and have it spill to the required length, if such a thing would be possible.

Current attempt

I have tried making this logic work through the combined used of =INDEX, =RANDBETWEEN =FILTER and a helper =RAND() column, in an attempt to filter the data, then randomly select from it. The issue I'm finding is that =FILTER does not like to combine properly (although I'm likely doing something wrong). Additionally, this involves copying the formula down to each cell I'd like a new randomly selected option for, which isn't ideal if possible.

Example of required output

IDT/FNumber to randomly select?Output
1TRUE52 [Formula is here and spill down]
2TRUE5
3FALSE7
4FALSE9
5TRUE12
6FALSE
7TRUE
8TRUE
9TRUE
10FALSE
11TRUE
12TRUE

Here is an example of how I'd ideally like the output of the data. The data itself is in A1:B13. I'd enter the number of options to randomly select in C2, then the output would be generated based on a solution contained in D2, which spills down accordingly. The requirements that it only selects from an ID population in column A where the TRUE/FALSE indicator from column B for that ID is TRUE. I'm looking for the solution to this question to be the formula I'd need to put into D2, please.

Extra detail

I'm always looking to improve, so any explanation on how something works is always appreciated, so I don't end up asking the same things again!

I am using MSO 365, but I am restricted to version 2108 due to rollout schedules.

Thanks for any help with this!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

亣腦蒛氧 2025-02-12 12:41:58

尝试:

“

d2中的公式:

=LET(X,FILTER(A2:A13,B2:B13),INDEX(SORTBY(X,RANDARRAY(COUNT(X))),SEQUENCE(C2),1))

或者,如果需要这些升级:

=LET(X,FILTER(A2:A13,B2:B13),SORT(INDEX(SORTBY(X,RANDARRAY(COUNT(X))),SEQUENCE(C2),1)))

最后一个小编辑可以是调整c2中的值如果需要的话,数量较小(避免泄漏出错误):

=LET(X,FILTER(A2:A13,B2:B13),SORT(INDEX(SORTBY(X,RANDARRAY(COUNT(X))),SEQUENCE(MIN(COUNTIF(B2:B13,TRUE),C2)),1)))

Try:

enter image description here

Formula in D2:

=LET(X,FILTER(A2:A13,B2:B13),INDEX(SORTBY(X,RANDARRAY(COUNT(X))),SEQUENCE(C2),1))

Or, if one needs these to be ascending:

=LET(X,FILTER(A2:A13,B2:B13),SORT(INDEX(SORTBY(X,RANDARRAY(COUNT(X))),SEQUENCE(C2),1)))

A last small edit could be to adjust the value in C2 with a smaller number if need be (avoid errors spilled down):

=LET(X,FILTER(A2:A13,B2:B13),SORT(INDEX(SORTBY(X,RANDARRAY(COUNT(X))),SEQUENCE(MIN(COUNTIF(B2:B13,TRUE),C2)),1)))
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文