按月字符串降序排序,按周字符串递增

时间:2017-12-05 06:35:04

标签: google-sheets

我有一个用于数据验证的列,按以下格式下拉:

M01 W01 random strings
M01 W02 random strings
M01 W03 random strings
M02 W01 random strings
M02 W02 random strings
M02 W03 random strings

M =月,W =周

现在我的列按降序排序,因此最近一个月排在最前面:

M02 W03 random strings
M02 W02 random strings
M02 W01 random strings
M01 W03 random strings
M01 W02 random strings
M01 W01 random strings

有没有办法对它进行排序,以便周数呈上升趋势:

M02 W01 random strings 
M02 W02 random strings
M02 W03 random strings
M01 W01 random strings
M01 W02 random strings
M01 W03 random strings

我认为regextract" M00"在一个范围内,然后使用它来查询排序原始列,但似乎无法使其工作:

= query({original column; regextract M00},"选择Col1,按Col2 desc排序"}

编辑:NVM我是一个白痴,我所要做的就是替换; with,in query {}。

1 个答案:

答案 0 :(得分:0)

为什么不定期sort功能?

=SORT(A:C,1,0,2,1)

enter image description here

修改

如果是1列,请先使用regex

=TRANSPOSE(QUERY(TRANSPOSE( SORT(IFERROR(REGEXEXTRACT(A:A,"(M\d{2}) (W\d{2}) (.*)")),1,0,2,1) ),,2^50))

transposequery部分是加入文字:

M02 W01 random strings
M02 W02 random strings
M02 W03 random strings
M01 W01 random strings
M01 W02 random strings
M01 W03 random strings