Sort and find Top and Bottom 5 values and their corresponding names - excel

I know this is not the first time someone is asking a similar question, but me trying to execute what I found out in other answers is not working exactly as how I want it to be. I hope someone here could help me.
I got four columns, the first one is the Product Name, and the last one is its P/L%. I want to sort out top and bottom 5 P/L% value along with their corresponding Product Name. I am attaching the screenshot of a sample scenario in case if you couldn't understand what I explained.
I tried the (sort(filter)) method as found somewhere else, but it actually messed up with the second and third columns. I hope someone here can give me some simple ways.

My solution considers the case when multiple products has same value in P/L% and I use a Table object for displayed data.
Formulas to use
Top 5 Gainers values
=LARGE(ProductTable[P/L%]; ROWS($H$3:H3)), and copy down
Top 5 Gainer values
Top 5 Gainers products name
=INDEX(ProductTable[Product Name];AGGREGATE(14;6;(ROW(ProductTable[P/L%])-ROW(D$2)+1)/(ProductTable[P/L%]=H3);COUNTIF($H$3:H3;H3))), and copy down
Top 5 Gainers products name
Top 5 Loosers values
=SMALL(ProductTable[P/L%];ROWS($H$3:H3)), and copy down
Top 5 Loosers values
Top 5 Loosers products name
=INDEX(ProductTable[Product Name];AGGREGATE(14;6;(ROW(ProductTable[P/L%])-ROW(D$2)+1)/(ProductTable[P/L%]=K3);COUNTIF($K$3:K3;K3))), and copy down
Top 5 Loosers products name
Short Explanation
You must use LARGE and SMALL functions when you want to get the largest or the smallest value in a data array.
AGGREGATE function is a little bit complex to explain here so I recommend you this link to understand better. Basically, I use this formula to get the row of the gainer or looser product name into INDEX function.
ROWS($H$3:H3) returns 1, but when you copy down this formula, you get 2, 3, and so on. This is a nice way to expand the query if you need more than top 5 values.
Similar problem in:
https://www.excelforum.com/excel-formulas-and-functions/1208726-index-match-large-and-duplicates.html

Related

How to identified the smaller number only from specific lines of a table

I am not familiar with excel as you can probaly guess by my question so I am sorry if it's a silly question but I have been googling for a long time and I can't do it.
I manage to do it in excel 365 with the function filter, but I can't on excel 2019 (I am required to do it in excel 2019)
I want to identifed the smaller number of a specific combination of cells using two table.
Table1 has name of people and places as well as a number. (the number shows the difference of the last time a person went to a place and the [in months])
(In this project the inspector cannot go to the same place twice unless 4 months have pass, thus why I want the smaller number, using the date of the last visited and the fcuntion now I get teh number of months that have pass)
Table2 has only the name of one person out of these people but has the name of all places. I want to get the smaller number for every place.
This is my table1: (I hided other peoples names so I can show a more compact examlplo)
And this is my table2:
I thought that I could use a function aggregate with a function if inside of it to get only the values that I desire.
It did not worked thou. Was I had miss undertand the fact that function if only gives me true or false. But thought that the aggregate function could wordk. It did not as well
=AGGREGATE(5;3;A2&B2=Table1[#Place]&Table1[#name];1).
overall my question could be summarize to which funtion should I used?
Which function should I use?
obs: In excel 365 I used concat to make a code an thus only used one cell, but I don't see why it wouldn't work if I just select two cells insted of one (teh concat cell)

Excel: Calculations with two variables, that both share the same ID

I have been working on a little project in which I analyze some data from a game that I play. My dataset looks like this:
As you can see, it consists of:
Match ID
Map the match was played on
Team name
First pick, second pick and third pick (characters/players)
Points the teams won from this match
What side they played on (A or B)
Who won
Whether they're in the top 64 teams
Currently I am trying to analyze how certain picks perform against other picks. For example, I would like to see how the Xelor first pick (cell D2) performs against all other first picks. To do this, I would need to count the amount of times the Xelor first pick played against all other first pick, and how many times the Xelor pick won. I don't have any problems doing that, but the catch is that I need to make sure I only compare the Xelor first picks with other first picks from the same match (same match ID). For example, I would compare the Xelor first pick (D2) vs the Steamer first pick (D3), as they share the same match ID.
I came up with a messy solution earlier with simple formulas, but it made for a table that had no data every other row, which resulted in some problems analyzing the data. I am now struggling with the Index and Match functions to make a pretty table for my needs, but I am having a hard time.
If anyone could give me a hand on how to do this, or has any clever ideas on how to analyze all picks vs other picks, let me know!
So, it turns out that both the Unique function and the Xlookup functions made this an easy problem to solve.
First, I made a new column showing just the unique match ID values:
=UNIQUE(A:A)
Then, next to that column I looked up the first pick of the A side team using Xlookup:
=XLOOKUP(M2;A:A;C:C;;0;1)
I then did the same in another column for the team on the other side using an inverse search direction:
=XLOOKUP(M2;A:A;C:C;;0;-1)
Lastly, to see which of the two first picks won, I used this formula in a fourth column:
=IF(XLOOKUP(M2;A:A;H:H;;0;1)="Win";N2;O2)
This resulted in the following table (M:P):
Thanks for the help, David!
You could try something like this in M2 cell:
=IF(L2="","",COUNTIFS(TB_GAMES[W/L/D],"Win",
TB_GAMES[Pick 1],L2,TB_GAMES[Match],$K$2))
Then you can expand the formula down.
In L column you have the unique values from users given the Match (K2) and the Pick 1 column values.
=UNIQUE(FILTER(TB_GAMES[Pick 1], TB_GAMES[Match]=K2))
Update
In case you want to calculate the scores for all the Pick 1 players at once. You can try the following:
=LET(winSet, FILTER(TB_GAMES[Pick 1], TB_GAMES[W/L/D]="Win"),
matches,XMATCH(winSet, UNIQUE(winSet)),
freq,FREQUENCY(matches, UNIQUE(matches)), SORT(HSTACK(UNIQUE(winSet),
FILTER(freq, freq<>0)),2,-1)
)
Note: Because we are using a FILTER function we cannot use as range input argument for COUNTIF or COUNTFS, so we try to use XMATCH/FREQUENCY as a way to achieve the same result. For more information about this see my answer to the question: How to count the number of trades made on a Excel spreadsheet using a custom conditional formula?, we use here the same idea and the explanation would be the same.
The HSTACK function is used just to combine the result having the winners and the number of wins for each player. Finally the result is sorted by score.
This would be the result on O2 cell:

Sum of Questionnaire Scores Based on a Domain Table

I have created a questionnaire that consists of around 100 questions. Participants are asked to fill them in online, where the items are shuffled each time. These items are separated into 6 domains where, for the sake of easier understanding, let's just call them Domain 1 - 6.
I have them typed in one specific table called "Correspondence", with format like below:
(An example)
Question No.|Domain
   1  |Domain A
   2  |Domain C
   3  |Domain A
   4  |Domain B
   5  |Domain A
   6  |Domain C
I used Google Form to generate a spreadsheet of RAW data of respondents, where it will help me mark the RAW Scores, for each item on a separate column:
(An example)
Submission ID|Question 1|Question 2|Question 3|Question 4|Question
5|Question 6
Participant 1 |  2  |  3  |  5   |  1   |  2   |  4   |
Participant 2 |  5  |  4  |  5   |  3   |  5   |  1   |
Participant 3 |  1  |  1  |  1   |  2   |  2   |  2   |
The next thing I need to do is generate another table that sums up the Domain totals for each participant. So from the example above, I need to sum 1,3,5 as Domain A, 4 as Domain B and 2 & 6 as Domain C:
(An example)
Participant 1
    |Domain A|Domain B|Domain C|
Total |  9  |  1  |  7   |
The hardest thing is to find a proper method to kick start this process. Can anyone point me in the right direction? Either formulas or VBAs would be fine too. Thanks!
This can be done if you are able to create a helper row.
First, I created a table to link the question to domain. That is named in my example as "Correspondence". This table is somewhat the answer key. From your description of the problem, you need a table like this to establish which question is associated with the domain/category/point system you want to use.
I then created a helper row for the survey results shown on row 9. This has =INDEX($B$3:$C$8,MATCH(B$10,$B$3:$B$8,0),2) in cell B9 as the code to reference the question to the domain. This is immediately above the questions in the example, but you can put it on a separate sheet if needed.
Then you can just sum them up.
=SUMPRODUCT(SUMIFS(INDIRECT(MATCH($E3,$A:$A,0)&":"&MATCH($E3,$A:$A,0)),$9:$9,F$2))
This formula uses MATCH, which returns an integer, inside INDIRECT to be used as a dynamic row reference. This will fail if the participant names are not unique. The SUMIFS inside the SUMPRODUCT allows the row to be treated like an array without using an array formula. So you can recreate the example I have and copy/paste or drag and paste the formulas as you wish.
A different approach may be that you want to sum up the points to the questions first and then do the conversion from question to domain. That way you don't ever have to manipulate the raw data, just the reports. That may be the better approach for you, actually.
Edit: Added information about the formulas and the example.

Index with double Match returns incorrect closest values

I have an planning exported to Excel which looks like the following (tab ' Data'):
Each production line has a number of people working on it. Now is my goal to show how many people are working on a line per minute. We plan per product group, and several product groups combined form waht a line has to do per minute.
To get the production per minute I created the following (tab 'Conversie'):
=INDEX(Data!$H$2:$H$157;MATCH($N$1&A4;Data!$B$2:$B$157&Data!$C$2:$C$157;1))
In the example it works correct. However, the formula doesn't seem to always return the correct "Artikelomschrijving"(H) every time. I get incorrect return values when I extend this formula to other product groups.
I read that the data needs to be sorted ascending cause I use match_type 1. When I do that I get the right returns for some product groups, but the given example suddenly returns incorrect values.
I can't sort both column C and A in ascending order for the formulas to always return correct items. Can you help me to get past this hurdle?
After a little bit of google translate work, if I'm understanding your question correctly, you need to find the "Item Description" (H) of the record where the "Line" (B) = the value in N1 and the time is between the start and end times.
This is an array formula, you have to confirm it with Ctrl+Shift+Enter
=INDEX(Data!$H$2:$H$157,MATCH(1,(Data!$B$2:$B$157=$N$1)*(Data!$C$2:$C$157<$A2)*(Data!$D$2:$D$157>=$A2),0))
OR with semicolon syntax:
=INDEX(Data!$H$2:$H$157;MATCH(1;(Data!$B$2:$B$157=$N$1)*(Data!$C$2:$C$157<$A2)*(Data!$D$2:$D$157>=$A2);0))
I found the solution, thank you for pointing me in the right direction Valon Miller. This is the formula I fixed it with:
=ALS.FOUT(INDEX(Data!$H$2:$H$154;MATCH(1;(Conversie!L$1=Data!$B$2:$B$154)*((Conversie!$A32>=Data!$C$2:$C$154)*(Conversie!$A32<=Data!$D$2:$D$154));0));"")

In Excel, how can i break ties when ranking students' tests?

I'm doing like a bit of a competition for my students in which they have a weekly test they have to complete and submit. The grade is stored in an excel column next to their names.
Following instructions i found, i was able to create a full working general TOP3 with the Average of the tests' grade and when i get to the TOP5 for the grades of the last submitted test, i get a three-way tie.
I use the LARGE function to find the top grades and the combination of the INDEX and MATCH functions to find and display the name associated to that mark.
(Something like this =INDEX($A$1:$A$29;MATCH(M12;$F$1:$F$29;0))
The problem is that the function compares the grade on it's left to find that value in the range of grades and then returns the corresponding name associated to that row; so, it returns the same name for the three grades.
I tried using an IF function to exclude the first-result-cell from the array in which the formula is looking so that when it finds a match it will be different from the previous one, but i have not manage to work it out...
You need to use a pivot table and filter the results to the top 3. A pivot table will display the ties.
Here is a link that #Jeeped gave which basically solves the problem!
Thank you all for commenting!
Multiple Ranked Returns from INDEX(…) with Duplicate Values:
http://tinyurl.com/naavhgf

Resources