Hi guys,
I am working on a model that let user filter data from a database though the new dynamic array Filter function with some criterias (in the enclosed example the criteria is only 1, City).
Then the model should let the user apply a "multilevel" sorting selecting from a series of cells with data validation, depending on the depth of levels the user need the sorting to be made. This selection is made through cells O2:O7 and Q2:Q7 for the corresponding sorting order.
The problem is that, using the dynamic array Sort function (but it would be exactly the same using the Sort-by function) I am only able to apply 1 single criteria sorting. I am not succeeding to build a formula that applies the sorting based upon the choices made by the user when sorting Levels are more than 1.
As per what I learnt about these two "new" functions, sorting multiple columns should be decided before writing the formula and cannot be based on flexible and dynamic criterias. Am I mistaking?
I would really appreciate your help about that, thanks a lot.
Hope to hear back from you guys,
Bye (and have an Happy Easter!)
Mark
I am working on a model that let user filter data from a database though the new dynamic array Filter function with some criterias (in the enclosed example the criteria is only 1, City).
Then the model should let the user apply a "multilevel" sorting selecting from a series of cells with data validation, depending on the depth of levels the user need the sorting to be made. This selection is made through cells O2:O7 and Q2:Q7 for the corresponding sorting order.
The problem is that, using the dynamic array Sort function (but it would be exactly the same using the Sort-by function) I am only able to apply 1 single criteria sorting. I am not succeeding to build a formula that applies the sorting based upon the choices made by the user when sorting Levels are more than 1.
As per what I learnt about these two "new" functions, sorting multiple columns should be decided before writing the formula and cannot be based on flexible and dynamic criterias. Am I mistaking?
I would really appreciate your help about that, thanks a lot.
Hope to hear back from you guys,
Bye (and have an Happy Easter!)
Mark
TEST_.xlsx | ||||||||||||||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z | AA | AB | AC | AD | |||
1 | Sort by: | Order: | column | order | ||||||||||||||||||||||||||||
2 | Quantity | Ascending | Level 1 | 5 | 1 | |||||||||||||||||||||||||||
3 | Level 2 | |||||||||||||||||||||||||||||||
4 | Level 3 | |||||||||||||||||||||||||||||||
5 | Level 4 | |||||||||||||||||||||||||||||||
6 | Level 5 | |||||||||||||||||||||||||||||||
7 | Level 6 | Boston | 1 | Region | Ascending | 1 | ||||||||||||||||||||||||||
8 | Filter by City | New York | 2 | City | Descending | -1 | ||||||||||||||||||||||||||
9 | Los Angeles | 3 | Category | |||||||||||||||||||||||||||||
10 | Region | City | Category | Product | Quantity | Turnover | Region | City | Category | Product | Quantity | Turnover | San Diego | 4 | Product | |||||||||||||||||
11 | East | Boston | Bars | Banana | 79 | 179,33 | West | Los Angeles | *******s | Whole Wheat | 42 | 146,58 | 5 | Quantity | ||||||||||||||||||
12 | East | Boston | Bars | Bran | 467 | 873,29 | West | San Diego | *******s | Whole Wheat | 48 | 167,52 | 6 | Turnover | ||||||||||||||||||
13 | East | Boston | Bars | Carrot | 1281 | 2267,37 | East | Boston | Bars | Banana | 79 | 179,33 | ||||||||||||||||||||
14 | East | Boston | Cookies | Arrowroot | 880 | 1918,4 | West | San Diego | Snacks | Potato Chips | 100 | 168,00 | ||||||||||||||||||||
15 | East | Boston | Cookies | Chocolate Chip | 642 | 1200,54 | East | New York | *******s | Whole Wheat | 141 | 492,09 | ||||||||||||||||||||
16 | East | Boston | Cookies | Oatmeal Raisin | 1184 | 3362,56 | West | Los Angeles | Cookies | Arrowroot | 185 | 403,30 | ||||||||||||||||||||
17 | East | Boston | *******s | Whole Wheat | 726 | 2533,74 | East | Boston | Snacks | Pretzels | 186 | 585,90 | ||||||||||||||||||||
18 | East | Boston | Snacks | Potato Chips | 205 | 344,4 | West | San Diego | Bars | Bran | 196 | 366,52 | ||||||||||||||||||||
19 | East | Boston | Snacks | Pretzels | 186 | 585,9 | West | San Diego | Cookies | Oatmeal Raisin | 202 | 573,68 | ||||||||||||||||||||
20 | East | New York | Bars | Bran | 563 | 1052,81 | East | Boston | Snacks | Potato Chips | 205 | 344,40 | ||||||||||||||||||||
21 | East | New York | Bars | Carrot | 1120 | 1982,4 | East | New York | Snacks | Potato Chips | 326 | 529,53 | ||||||||||||||||||||
22 | East | New York | Cookies | Arrowroot | 929 | 2025,22 | West | Los Angeles | Bars | Bran | 349 | 652,63 | ||||||||||||||||||||
23 | East | New York | Cookies | Chocolate Chip | 470 | 878,9 | West | Los Angeles | Snacks | Potato Chips | 363 | 609,84 | ||||||||||||||||||||
24 | East | New York | Cookies | Oatmeal Raisin | 457 | 1297,88 | West | San Diego | Cookies | Arrowroot | 451 | 983,18 | ||||||||||||||||||||
25 | East | New York | *******s | Whole Wheat | 141 | 492,09 | East | New York | Cookies | Oatmeal Raisin | 457 | 1.297,88 | ||||||||||||||||||||
26 | East | New York | Snacks | Potato Chips | 326 | 529,53 | East | Boston | Bars | Bran | 467 | 873,29 | ||||||||||||||||||||
27 | West | Los Angeles | Bars | Bran | 349 | 652,63 | East | New York | Cookies | Chocolate Chip | 470 | 878,90 | ||||||||||||||||||||
28 | West | Los Angeles | Bars | Carrot | 1262 | 2233,74 | West | San Diego | Cookies | Chocolate Chip | 496 | 927,52 | ||||||||||||||||||||
29 | West | Los Angeles | Cookies | Arrowroot | 185 | 403,3 | West | San Diego | Bars | Carrot | 524 | 927,48 | ||||||||||||||||||||
30 | West | Los Angeles | Cookies | Chocolate Chip | 837 | 1565,19 | East | New York | Bars | Bran | 563 | 1.052,81 | ||||||||||||||||||||
31 | West | Los Angeles | Cookies | Oatmeal Raisin | 731 | 2076,04 | East | Boston | Cookies | Chocolate Chip | 642 | 1.200,54 | ||||||||||||||||||||
32 | West | Los Angeles | *******s | Whole Wheat | 42 | 146,58 | East | Boston | *******s | Whole Wheat | 726 | 2.533,74 | ||||||||||||||||||||
33 | West | Los Angeles | Snacks | Potato Chips | 363 | 609,84 | West | Los Angeles | Cookies | Oatmeal Raisin | 731 | 2.076,04 | ||||||||||||||||||||
34 | West | San Diego | Bars | Bran | 196 | 366,52 | West | Los Angeles | Cookies | Chocolate Chip | 837 | 1.565,19 | ||||||||||||||||||||
35 | West | San Diego | Bars | Carrot | 524 | 927,48 | East | Boston | Cookies | Arrowroot | 880 | 1.918,40 | ||||||||||||||||||||
36 | West | San Diego | Cookies | Arrowroot | 451 | 983,18 | East | New York | Cookies | Arrowroot | 929 | 2.025,22 | ||||||||||||||||||||
37 | West | San Diego | Cookies | Chocolate Chip | 496 | 927,52 | East | New York | Bars | Carrot | 1.120 | 1.982,40 | ||||||||||||||||||||
38 | West | San Diego | Cookies | Oatmeal Raisin | 202 | 573,68 | East | Boston | Cookies | Oatmeal Raisin | 1.184 | 3.362,56 | ||||||||||||||||||||
39 | West | San Diego | *******s | Whole Wheat | 48 | 167,52 | West | Los Angeles | Bars | Carrot | 1.262 | 2.233,74 | ||||||||||||||||||||
40 | West | San Diego | Snacks | Potato Chips | 100 | 168 | East | Boston | Bars | Carrot | 1.281 | 2.267,37 | ||||||||||||||||||||
41 | ||||||||||||||||||||||||||||||||
42 | ||||||||||||||||||||||||||||||||
43 | ||||||||||||||||||||||||||||||||
44 | ||||||||||||||||||||||||||||||||
45 | ||||||||||||||||||||||||||||||||
46 | ||||||||||||||||||||||||||||||||
47 | ||||||||||||||||||||||||||||||||
48 | ||||||||||||||||||||||||||||||||
DATABASE |
Cell Formulas | ||
---|---|---|
Range | Formula | |
U2 | U2 | =IF(Q2<>"",XLOOKUP(Q2,$AB$7:$AB$8,$AC$7:$AC$8),"") |
T2:T7 | T2 | =IF(O2<>"",XLOOKUP(O2,$Z$7:$Z$12,$Y$7:$Y$12),"") |
H11:M40 | H11 | =SORT(FILTER(Sales_Data,Sales_Data[City]=I8,Sales_Data),T2,U2) |
Dynamic array formulas. |
Cells with Data Validation | ||
---|---|---|
Cell | Allow | Criteria |
I8 | List | =$W$7:$W$11 |
O2:O7 | List | =$Z$7:$Z$13 |
Q2:Q7 | List | =$AB$7:$AB$8 |