excel选择并随机化

时间:2017-05-24 18:54:46

标签: database excel

我仍在努力解决这个问题。我在excel中将这些数据放在一张表中。

City         Risk Level
Facility 1  Extremely Low Risk
Facility 2  Very High Risk
Facility 3  Very Low Risk
Facility 4      Low Risk
Facility 5    Moderate Risk
Facility 6    Moderate Risk
Facility 7     High Risk
Facility 8     Extremely Low Risk
Facility 9     Very Low Risk
Facility 10     Low Risk
Facility 11    Moderate Risk
Facility 12   Extremely Low Risk
Facility 13     Very High Risk
Facility 14     Very Low Risk
Facility 15      Low Risk
Facility 16      Moderate Risk
Facility 17        Highly Moderate Risk
Facility 18       High Risk
Facility 19      Extremely Low Risk
Facility 20       Very Low Risk
Facility 21        Low Risk
Facility 22        Moderate Risk
Facility 23        Highly Moderate Risk
Facility 24        High Risk
Facility 25      Very High Risk
Facility 26       Extremely Low Risk
Facility 27        Very Low Risk
Facility 28         Low Risk
Facility 29        Moderate Risk

Risk Levels          Desired
Extremely Low Risk      3
Very Low Risk           4
Low Risk                4
Moderate Risk           5
Highly Moderate Risk    2
High Risk               2
Very High Risk          1

我想知道是否有一个公式可以从每个风险等级中选择所需数量的设施。例如:3个设施“极低风险”,4个设施“极低风险”,4个设施“低风险”,5个设施“中度风险”等等......我希望选择设施随机,我希望设施的名称显示在列中,而不是行。

请告诉我如何才能做到这一点。

提前非常感谢你。

1 个答案:

答案 0 :(得分:1)

您可以使用以下公式:

=IF(COLUMN(A:A)<=$E2,INDEX($A:$A,AGGREGATE(15,6,ROW($B$2:$B$30)/(($B$2:$B$30=$D2)*(COUNTIF($E$2:E2,$A$2:$A$30)=0)),RANDBETWEEN(1,COUNTIF($B$2:$B$30,$D2)-COLUMN(A:A)+1))),"")

enter image description here