简体   繁体   English

Excel - 在公式中使用 2 个或更多标准对数据进行排序(从小到大)?

[英]Excel - sort data (smallest to largest) with 2 or more criteria in formula?

I am trying to find result of sort data in table with specific criteria我正在尝试在具有特定条件的表中查找排序数据的结果

for example:例如:

[1]:https://i.stack.imgur.com/f7bQN.jpg

yellow is ALL-JOB fill by user RED is unfinished JOB sort by "START DATE" Green is completed JOB sort by "END DATE" and "JOB ID"黄色是用户填写的所有作业 红色是未完成的作业按“开始日期”排序 绿色是已完成的作业按“结束日期”和“作业 ID”排序

i need to sorting data in yellow table and show result in red/green table,smallest to largest我需要对黄色表格中的数据进行排序并在红色/绿色表格中显示结果,从最小到最大

Any help would be greatly appreciated.任何帮助将不胜感激。 Thank you so much in advance.非常感谢你。

ps.My English is not good. ps.我的英文不好。 Please forgive me if I make grammatical mistakes.如果我犯了语法错误,请原谅我。

With the new Dynamic Array Functions(Currently only available to Office 365 Insiders) a couple formula will do what you want quickly:使用新的动态数组函数(目前仅适用于 Office 365 预览体验成员),几个公式可以快速完成您想要的操作:

First for the Red data, In G3 put:首先对于红色数据,在 G3 中输入:

=SORTBY(FILTER(B3:D100,(D3:D100="")*(B3:B100<>""),""),FILTER(B3:B100,(D3:D100="")*(B3:B100<>""),""))

Then in F3 put:然后在 F3 中输入:

=SEQUENCE(ROWS(G3#))

In L3:在 L3 中:

=SORTBY(FILTER(B3:D100,(D3:D100<>"")*(B3:B100<>""),""),FILTER(D3:D100,(D3:D100<>"")*(B3:B100<>""),""),1,FILTER(C3:C100,(D3:D100<>"")*(B3:B100<>""),""),-1)

and in K3:在 K3 中:

=SEQUENCE(ROWS(L3#))

And Excel will spill the data accordingly without the need to copy paste formula into all the cells.并且 Excel 将相应地溢出数据,而无需将粘贴公式复制到所有单元格中。

在此处输入图像描述


Without the dynamic array functions we need to resort to INDEX/AGGREGATE and only one sort, the second adds too much to the function.如果没有动态数组函数,我们需要求助于 INDEX/AGGREGATE 并且只有一种排序,第二种对 function 增加了太多。

Start by sorting the original data by the Job number then use the following首先按作业编号对原始数据进行排序,然后使用以下内容

In G3 put:在 G3 中:

=IFERROR(INDEX(B:B,AGGREGATE(15,7,ROW($B$3:$B$17)/((AGGREGATE(15,7,$B$3:$B$17/(($D$3:$D$17="")*(COUNTIFS($H$2:$H2,$B$3:$B$17)=0)),ROW($ZZ1))=$B$3:$B$17)*($D$3:$D$17="")*(COUNTIFS($H$2:$H2,$C$3:$C$17)=0)),1)),"")

Copy over and down the range.在范围内上下复制。 Then in F3 Put:然后在 F3 放:

=IF(G3<>"",ROW($ZZ1),"")

Then copy down the range然后复制范围

for the other, Put this in L3:对于另一个,把它放在 L3 中:

=IFERROR(INDEX(B:B,AGGREGATE(15,7,ROW($B$3:$B$17)/((AGGREGATE(15,7,$D$3:$D$17/(($D$3:$D$17<>"")*(COUNTIFS($H$2:$H2,$B$3:$B$17)=0)),ROW($ZZ1))=$D$3:$D$17)*($D$3:$D$17<>"")*(COUNTIFS($H$2:$H2,$C$3:$C$17)=0)),1)),"")

And copy over and down the range.并在范围内上下复制。 Then in K3 put然后在K3放

=IF(L3<>"",ROW($ZZ1),"")

Copy down the range.向下复制范围。

在此处输入图像描述


With both you will need to format the output cells with the number format desired.两者都需要使用所需的数字格式格式化 output 单元格。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM