如何在Excel/Google表中仅扭转仅一列的顺序?

发布于 2025-01-20 17:06:13 字数 471 浏览 0 评论 0原文

我有一个如下所示的表格:

Date   Home    Away
4/12   NY      TEX
4/12   TOR     ARI
4/12   LA      CIN
4/13   PHI     MIN
4/13   UTA     DEN
4/13   NAS     WYO

当我按日期从 A 到 Z 或 Z 到 A 排序时,主队和客队保持相同的顺序。如何使“主页”和“离开”列颠倒其当前顺序?这意味着结果将如下所示:

Date   Home    Away
4/12   LA      CIN
4/12   TOR     ARI
4/12   NY      TEX
4/13   NAS     WYO
4/13   UTA     DEN
4/13   PHI     MIN

我什至不介意日期列是否以不同方式排序,我只需要“家庭”和“离开”列按日期反转其顺序。先感谢您!

I have a table that looks like this:

Date   Home    Away
4/12   NY      TEX
4/12   TOR     ARI
4/12   LA      CIN
4/13   PHI     MIN
4/13   UTA     DEN
4/13   NAS     WYO

When I sort by Date either A to Z or Z to A, the Home and Away teams stay in the same order. How can I make the Home and Away columns reverse their current order? Meaning the result would look like this:

Date   Home    Away
4/12   LA      CIN
4/12   TOR     ARI
4/12   NY      TEX
4/13   NAS     WYO
4/13   UTA     DEN
4/13   PHI     MIN

I don't even mind if the date column gets sorted differently, I just need the Home and Away columns to reverse their order by Date. Thank you in Advance!

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

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

发布评论

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

评论(3

吝吻 2025-01-27 17:06:13

还可以尝试在行降序上进行分类:

=SORTBY(A2:C7,A2:A7,1,ROW(A2:A7),-1)

=VSTACK(A1:C1,SORTBY(A2:C7,A2:A7,1,ROW(A2:A7),-1))

甚至还

=VSTACK(A1:C1,HSTACK(TEXT(A2:A7,"DD-MMM"),SORTBY(B2:C7,A2:A7,1,ROW(A2:A7),-1)))

包括日期格式。

Could also try sorting on row descending:

=SORTBY(A2:C7,A2:A7,1,ROW(A2:A7),-1)

enter image description here

=VSTACK(A1:C1,SORTBY(A2:C7,A2:A7,1,ROW(A2:A7),-1))

(copied from @JvdV) to include headers.

or even

=VSTACK(A1:C1,HSTACK(TEXT(A2:A7,"DD-MMM"),SORTBY(B2:C7,A2:A7,1,ROW(A2:A7),-1)))

to include the date formatting as well.

沫尐诺 2025-01-27 17:06:13

我想通了。为此,我必须再创建 3 列...第一列为“日期”列中每次出现的日期创建一个值。看起来像这样:

=COUNTIF($A$1:A2,A2)

然后我将公式拖到整个数据中。所以现在我的表看起来像这样:

Date   Home    Away  Sort
4/12   NY      TEX   1
4/12   TOR     ARI   2
4/12   LA      CIN   3
4/13   PHI     MIN   1
4/13   UTA     DEN   2
4/13   NAS     WYO   3

创建下一列以反转按日期排序的顺序:

=MAXIFS(D:D,A:A,A2) - D2 + 1

然后拖动到底部,新表看起来像这样:

Date   Home    Away  Sort RevSort
4/12   NY      TEX   1    3
4/12   TOR     ARI   2    2
4/12   LA      CIN   3    1
4/13   PHI     MIN   1    3
4/13   UTA     DEN   2    2
4/13   NAS     WYO   3    1

我的第三列连接了日期和 RevSort 列,为我提供了唯一的行,其中然后,我可以对连接的列进行排序,并按照我想要的方式对表格进行排序。

I figured it out. I had to create 3 more columns to do so... The first column created a value for each occurrence of date in the Date column. That looked like this:

=COUNTIF($A$1:A2,A2)

I then dragged the formula throughout the data. So now my table looked like this:

Date   Home    Away  Sort
4/12   NY      TEX   1
4/12   TOR     ARI   2
4/12   LA      CIN   3
4/13   PHI     MIN   1
4/13   UTA     DEN   2
4/13   NAS     WYO   3

The next column was created to reverse the order of the sort by date:

=MAXIFS(D:D,A:A,A2) - D2 + 1

Then dragged to the bottom and the new table looked like this:

Date   Home    Away  Sort RevSort
4/12   NY      TEX   1    3
4/12   TOR     ARI   2    2
4/12   LA      CIN   3    1
4/13   PHI     MIN   1    3
4/13   UTA     DEN   2    2
4/13   NAS     WYO   3    1

My third column Concatenated the Date and RevSort column giving me unique rows which I could then Sort the concatenated column and get my table sorted the way I wanted to.

雪化雨蝶 2025-01-27 17:06:13

如果您希望表按日期以外的其他内容排序,则按日期以外的列排序。

如果您希望按主队 AZ 排序,请对主队列 AZ 与选定的所有其他列进行排序。

Sort by a column other than date if you want the table sorted by something other than date.

If you want it sorted by home team A-Z then sort the home team column A-Z with all other columns selected.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文