Sep 17 2021 08:41 AM
how to create a button that sorts by one column and then assigns an order in another column from one to 20.
Sep 17 2021 10:19 AM
SolutionSep 25 2021 11:37 PM
if you have 20 rows that have been sorted say by their %
then in another column you need show the ranking/position from 1-20
which would be 1-20 if all % were different but if for some reason some are the same
ie the top 3, then their ranking would be 1 but the next position would be 4th and so on to the bottom if that makes sense.
Sep 26 2021 01:24 AM
@Bazz02 Depending on your needs and below assuming Excel 365, it can be done in multiple ways and without a macro-button.
Having data in a (pyamas) table you can calculate the rank using a column formula
=XMATCH([@Value];SORT([Value]))
...finding the value on the same row (@ = single cell intersection) among all values sorted, and returning the number of the first match.
You may sort that column using the arrow in cell C2
Since it is an interesting education example I added some more solutions outside the table;
Cell E3 sorts the table each time data changes. It is a formula in only one cell but it 'spills' the result to as many cells that are needed.
=SORT(Table1[[Text]:[Value]];2)
G3 isolates the percentages in F3:F8 by addressing E3# (includes the full spill area) and intersects it with column F using the multiple cell intersection character space.
=XMATCH(E3# F:F;E3# F:F)
If you need to redesign the layout, it may be more handy to not include a column reference and then INDEX is a solution where row number zero returns all the rows and the two tells the second col.
=XMATCH(INDEX(E3#;0;2);INDEX(E3#;0;2))
LET is yet a rather new possibility to build a complex formula step by step. Use alt+Return for line breaks.
The last row/parameter is what is shown as the output of the calculation.
=LET(range;Table1[Value];
data;SORT(range);
output;XMATCH(data;data);
output
)
Sep 26 2021 01:59 AM
Sep 26 2021 02:26 AM
Following up some of the ideas already presented,
is returned by the formula
= LET(
ranking, RANK(Table1[Value],Table1[Value],-1),
output, IF({0,1}, Table1[Text], ranking),
SORT(output)
)
The ranking is placed first because, for some mysterious reason, RANK requires range references and not arrays. The next row is a device to combine the newly calculated rankings with the text column before it is sorted by rank.
Sep 26 2021 04:09 AM - edited Sep 26 2021 11:35 PM
I see that absolute references static arrays comes more and more handy.
Using CHOOSE allows to combine multiple dynamic arrays.
=SORT(CHOOSE({3\1\2}; Table1[Text]; Table1[Value]; Table1[Rank]))
Also noted that RANK is around for backwards compatibility.
Sep 27 2021 07:07 AM
Sep 28 2021 01:20 AM
[x] Like Tables
I do though stress, during classes, that when you work with column formulas you enter it...
...and in one step gets the formula, a new column and the column filled with that formula.
When undoing though, it demands three Ctrl+Z. One for each step.
The risk is when making a less visible change and typing Ctrl+Z, it is very easy to not have undone the change as expected. In the rest of the envirnment it is normally one change and one undo.
The only hint is a tiny green corner telling that the cell deviates.
I don't have any other suggestion for the interface - I'm confident that Microsoft have come up with the best solution among alternatives. Just notice that it is an area with a risk for unwanted results.
Sep 28 2021 03:55 AM
It can be something of a pitfall. As a 365 dynamic array user, I tend to expect consistency and follow Ray Panko (EuSpRIG papers) in treating any individually edited term as a Latent Error (i.e. one that may deliver the correct numbers now but with no assurance that it will continue to do so during the life of the spreadsheet). I would prefer that all edits should propagate and there should be no option to change a single term, but that would cause howls of protest.
It is not as if any other aspect of traditional spreadsheet development makes an attempt to be robust to change, so the Microsoft default is probably a good solution, though you are correct to warn against the risk.
Working my way, I would have
= IF([@precision]="high",
PI(),
355/113)
which, I agree, is somewhat cumbersome.
Sep 28 2021 07:06 AM
IMHO, that's always the risk to use the tool by the way it's not designed for. Structured table assumes same formula for entire column and keeps it as default formula for the column in background.
Sep 29 2021 12:43 PM
Sep 29 2021 12:46 PM
Sep 17 2021 10:19 AM
Solution