I am stuck on this and would love some help
Here is my table
Product | Type | Ranking |
---|---|---|
Gum | Wrigley | 4 |
Candy | Skittles | 3 |
Milk | Whole | 2 |
Bread | Wheat | 1 |
I would like to select the top 3 rows (Amount of Rows) based on ranking and only the first two columns:
So end result would look like this:
Product | Type |
---|---|
Gum | Wrigley |
Candy | Skittles |
Milk | Whole |
I tried everything to figure this out
CodePudding user response:
If what you want is to only view the top 3 rows then what you need is to filter your data to only use the top 3 (or any threshold) values.
You can find the filter option at the top right under the Home tab or you can use ctrl shift L and it will automatically show arrows at the top rows. Then you just need to click on the arrows and select Number Filters. Then you can select whichever element is most relevant to you
If what you want is to sort your data then you already have a column for ranking. All you need is to sort the data from high to low and BAMMM!!! you got your top rows
CodePudding user response:
There are multiple ways of doing it. In cell E2
:
=FILTER(A2:B5, ISNUMBER(XMATCH(C2:C5, LARGE(C2:C5,{1;2;3}))))
Assuming you want the top three rows based on Ranking value, your input data is sorted, but in general, it maybe not be the case.
You can replace the array with: SEQUENCE(3,1)
for a more general case.
If your excel version has available the DROP/CHOOSECOLS
functions then we can use SORT
, then remove the last column, and finally select the first three rows:
=CHOOSEROWS(DROP(SORT(A2:C5,3, -1),,-1), SEQUENCE(3,1))