英文:
Advanced Excel Table Sorting
问题
我需要按照以下方式排序我的电子表格:
总体排序标准是基于仓库、货架位置和如果产品在“拣选”列中被指定为“是”的话。您会注意到红色文本是按照仓库的字母顺序升序排序,然后是按照货架位置排序。
然而,我需要找到所有与产品代码匹配的其他仓库位置,并将该数据显示在相同的产品代码下方,但此数据必须按照最佳食用日期(BBD)排序,然后显示仓库、货架位置和货架。
这个电子表格是为了帮助仓库存储糖果的最佳食用日期轮换而设计的。它将允许人们在仓库的每个货架上四处走动,并打印出一个表格,显示按照它们出现在该仓库中的位置排序的拣选货架位置,同时还显示了按照BBD排序的各种其他仓库中存储相同产品的所有其他位置。
我不知道如何实现这个解决方案。VBA?数据透视表?还是可以通过函数来实现?
英文:
I need to sort my spreadsheet as follows:
The overall sorting criteria is based on the WAREHOUSE, BAY LOCATION and SHELF IF the product has been designated "YES" in the PICKING Column. You will notice the text in red is sorted alphabetically in ascending order by WAREHOUSE then by BAY LOCATION.
HOWEVER I need to find all other warehouse locations that match the PRODUCT CODE and display that data underneath that same PRODUCT CODE but this data must be sorted by BBD and then display the WAREHOUSE, BAY LOCATION and SHELF.
This spreadsheet is to help with Best Before Date rotation in a Warehouse that stores Candy. It will allow people to walk around the warehouse bay by bay and have a printed out sheet that displays the picking bay locations sorted in the location they appear in that warehouse while also displaying all the other locations that same product is stored in various other warehouses ordered by BBD.
I do not know what road to go down to achieve this solution. VBA? Pivot Table? or can it be achieved through functions?
答案1
得分: 2
以下是翻译好的部分:
如果我理解正确,您的意思是首先根据仓库/湾位/货架上设置为拣选 = "YES" 的产品以升序排序,但保持拣选 = "No" 的行位于同一产品代码行下,并根据BBD / 仓库/湾位/货架对它们进行排序。
我们可以在Microsoft 365中使用以下公式来实现这一点:
o, HSTACK(d,XMATCH(INDEX(d,,1),
TAKE(SORT(FILTER(CHOOSECOLS(d,3,4,5,1),INDEX(d,,6)="YES"),{1,2,3,4}),,-1))),
DROP(
SORT(o,
{7,6,2,3,4,5},
{1,-1,1,1,1,1}),
,-1))
解释:
我将您的示例数据更改为随机顺序,并更改了一个仓库的拣选类型为“是”,以更好地演示过滤顺序:
未排序的数据:
产品代码 | BBD | 仓库 | 湾位 | 货架 | 拣选 |
---|---|---|---|---|---|
Scooters | 03/03/2023 | 7 | C01 | 3 | No |
Bikes | 01/01/2023 | 6 | A02 | 1 | YES |
Buggy | 01/01/2023 | 8 | A03 | 1 | YES |
Bikes | 02/02/2023 | 9 | B02 | 3-4 | No |
Scooters | 02/02/2023 | 6 | B02 | 2-3 | No |
Buggy | 03/03/2023 | 4 | C03 | 3 | No |
Scooters | 01/01/2023 | 8 | A01 | 1 | YES |
Bikes | 03/03/2023 | 8 | C02 | 4 | No |
Buggy | 02/02/2023 | 5 | B03 | 3 | No |
在此示例中,以下行的拣选为“是”:
产品代码 | BBD | 仓库 | 湾位 | 货架 | 拣选 |
---|---|---|---|---|---|
Bikes | 01/01/2023 | 6 | A02 | 1 | YES |
Buggy | 01/01/2023 | 8 | A03 | 1 | YES |
Scooters | 01/01/2023 | 8 | A01 | 1 | YES |
由于您希望根据仓库/湾位/货架进行升序排序,这将设置顺序:
产品代码 | 顺序 | 说明 |
---|---|---|
Bikes | 1 | 仓库6<8 |
Scooters | 2 | 湾A01< A03 |
Buggy | 3 | 湾A03 > A01 |
然后,如果我们在这个顺序矩阵中查找表的产品代码,并将结果附加到表中,这将变成:
产品代码 | BBD | 仓库 | 湾位 | 货架 | 拣选 | 顺序 |
---|---|---|---|---|---|---|
Scooters | 03/03/2023 | 7 | C01 | 3 | No | 2 |
Bikes | 01/01/2023 | 6 | A02 | 1 | YES | 1 |
Buggy | 01/01/2023 | 8 | A03 | 1 | YES | 3 |
Bikes | 02/02/2023 | 9 | B02 | 3-4 | No | 1 |
Scooters | 02/02/2023 | 6 | B02 | 2-3 | No | 2 |
Buggy | 03/03/2023 | 4 | C03 | 3 | No | 3 |
Scooters | 01/01/2023 | 8 | A01 | 1 | YES | 2 |
Bikes | 03/03/2023 | 8 | C02 | 4 | No | 1 |
Buggy | 02/02/2023 | 5 | B03 | 3 | No | 3 |
然后,我们可以在排序条件中使用此最后一列,以将相似的产品代码放在一起,并根据其他条件对拣选行进行排序。
英文:
If I understood it correctly you mean to first sort the products that are set to picking = "YES" based on the Warehouse / Bay Location / Shelf in ascending order, but keep the picking = "No" lines underneath the same product code lines and have them sorted on the BBD / Warehouse / Bay Location / Shelf.
We could do this in Microsoft 365 using the following formula:
=LET(d, A2:F10,
o, HSTACK(d,XMATCH(INDEX(d,,1),
TAKE(SORT(FILTER(CHOOSECOLS(d,3,4,5,1),INDEX(d,,6)="YES"),{1,2,3,4}),,-1))),
DROP(
SORT(o,
{7,6,2,3,4,5},
{1,-1,1,1,1,1}),
,-1))
Explanation:
I changed you sample data to be in random order and changed one of the warehouses for the picking Yes
type, to demonstrate the filter order better:
unsorted data:
Product Code | BBD | Warehouse | Bay Location | Shelf | Picking |
---|---|---|---|---|---|
Scooters | 03/03/2023 | 7 | C01 | 3 | No |
Bikes | 01/01/2023 | 6 | A02 | 1 | YES |
Buggy | 01/01/2023 | 8 | A03 | 1 | YES |
Bikes | 02/02/2023 | 9 | B02 | 3-4 | No |
Scooters | 02/02/2023 | 6 | B02 | 2-3 | No |
Buggy | 03/03/2023 | 4 | C03 | 3 | No |
Scooters | 01/01/2023 | 8 | A01 | 1 | YES |
Bikes | 03/03/2023 | 8 | C02 | 4 | No |
Buggy | 02/02/2023 | 5 | B03 | 3 | No |
In this example the following lines are Picking "Yes":
Product Code | BBD | Warehouse | Bay Location | Shelf | Picking |
---|---|---|---|---|---|
Bikes | 01/01/2023 | 6 | A02 | 1 | YES |
Buggy | 01/01/2023 | 8 | A03 | 1 | YES |
Scooters | 01/01/2023 | 8 | A01 | 1 | YES |
As you want these sorted ascending based on the Warehouse / Bay Location / Shelf, this will set the order:
Product Code | Order | explanation |
---|---|---|
Bikes | 1 | warehouse 6<8 |
Scooters | 2 | Bay A01<A03 |
Buggy | 3 | Bay A03>A01 |
If we than lookup the product codes of the table in this order matrix and append the results to the table, this would make:
Product Code | BBD | Warehouse | Bay Location | Shelf | Picking | Order |
---|---|---|---|---|---|---|
Scooters | 03/03/2023 | 7 | C01 | 3 | No | 2 |
Bikes | 01/01/2023 | 6 | A02 | 1 | YES | 1 |
Buggy | 01/01/2023 | 8 | A03 | 1 | YES | 3 |
Bikes | 02/02/2023 | 9 | B02 | 3-4 | No | 1 |
Scooters | 02/02/2023 | 6 | B02 | 2-3 | No | 2 |
Buggy | 03/03/2023 | 4 | C03 | 3 | No | 3 |
Scooters | 01/01/2023 | 8 | A01 | 1 | YES | 2 |
Bikes | 03/03/2023 | 8 | C02 | 4 | No | 1 |
Buggy | 02/02/2023 | 5 | B03 | 3 | No | 3 |
We can then use this last column in the sort criteria, to keep similar product codes together and still have the picking lines be sorted based on the other criteria.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论