I am working with an excel file where I need a unique number created if the text in two cells are present: example
Text 1 Text 2 Value
star comet 100
star asteroid 101
asteroid nova 102
nova star 103
asteroid nova 102
star comet 100
nova star 103
I assume its something to do with the IF function but I'm now completely snowblind. Any help?
Thanks
Sort by column1 then by column 2
Use the Excel distinct function
Then add sequential ID to each row.
If you need to, use VLOOKUP to add the IDs to the original sheet
Without sorting, array formulae or VBA and assuming Text 1 is in A1, select ColumnsA:B, DATA > Sort & Filter - Advanced, Copy to: F1 (say), check Unique record only. In H2:
=F2&"|"&G2
in I2 enter 100 and copy H2:I2 down to suit.
In C2:
=VLOOKUP(A2&"|"&B2,H:I,2,0)
and copy down to suit.
A PivotTable is an alternative for constructing a list of unique pairs.
Related
I've got a few thousand rows in an excel spreadsheet, which (simplified) looks like this:
ID Category Animal Version Value
100 A Dog 1 20
100 B Cat 2 50
100 C Dog 3 50
200 A Dog 1 100
200 A Cat 2 100
300 B Cat 1 80
400 C Dog 1 80
I need to have the row with the highest/max version for each group of ids listed.
So in other words, I'd want these showing:
ID Category Animal Version Value
100 C Dog 3 50
200 A Cat 2 100
300 B Cat 1 80
400 C Dog 1 80
Is this possible?
Finding and showing the maxima/minima for grouped data with a single formula in only one cell can be done with the following formula:
=UNIQUE(FILTER(MyArray,MMULT(((ValueRange>TRANSPOSE(ValueRange))+(ValueRange=TRANSPOSE(ValueRange))-(GroupRange=TRANSPOSE(GroupRange)))*(GroupRange=TRANSPOSE(GroupRange)),SEQUENCE(ROWS(GroupRange),1,1,0))=0),FALSE,FALSE)
For an example, see this screenshot: Link
The output automatically adjusts for any number of groups in the data array.
With the operator > used in the formula, it will return the maximum. By using < it will return the minimum.
Note that the UNIQUE() function will only show distinct rows for each group maximum (see group 'Alpha' in screenshot).
If there is more than one maximum in a group and more than just the group and value column, the UNIQUE() function will show all distinct rows taking into account all columns (as can be seen for group 'Alpha' and 'Gamma' here: Link).
You can use the Advanced Filter with a formula criteria:
=D9=AGGREGATE(14,6,1/(A9=Table1[ID])*Table1[Version],1)
where D9 is the location of the first entry in the Value Column
Before applying Filter
After applying Filter
Suppose your data is in range A1:E8,
In cell A11, put in the following formula to find unique ID, drag it down until there is a #N/A error:
=INDEX($A$2:$A$8,MATCH(0,INDEX(COUNTIF($A$10:A10,$A$2:$A$8),0),0))
In cell B11, put in the following formula and drag it down to find the latest Version:
=AGGREGATE(14,6,$D$2:$D$8/($A$2:$A$8=A11),1)
In cell C11, D11 and E11, put in the following formulas respectively and drag them down to find the corresponding Category, Animal and Value:
=INDEX($B$2:$B$8,MATCH(1,INDEX(($A$2:$A$8=A11)/($D$2:$D$8=B11),0),0))
=INDEX($C$2:$C$8,MATCH(1,INDEX(($A$2:$A$8=A11)/($D$2:$D$8=B11),0),0))
=INDEX($E$2:$E$8,MATCH(1,INDEX(($A$2:$A$8=A11)/($D$2:$D$8=B11),0),0))
Let me know if there is any question. Cheers :)
For a list without duplicates you can put this in cell G2 ARRAY-FORMULA: CTRL + SHIFT + ENTER
=IFERROR(INDEX(A:A,MATCH(1,(COUNTIF(G$1:G2,A$1:A$99)=0)*(A$1:A$99<>""),0)),"")
This gives you a list with unique ID's. Now you can use the max formula to get the max version number of each ID. ARRAY-FORMULA: CTRL + SHIFT + ENTER
=MAX(IF($A$2:$A$2000=G3,$D$2:$D$2000,0))
The rest can be done with INDEX/MATCH formulas.
The first Excel file contains item analysis data for each student in the class:
Student ID Item # Response
101 1 A
101 2 B
101 3 D
101 4 B
Granted, this is just an excerpt of a file that has 500 unique student IDs.
In the second Excel file, I have the final grades for each student:
Student ID Grade
101 95
102 87
103 65
104 72
Again, this second Excel file has 500 unique student IDs. I need to make a file that essentially looks like the second Excel file, where each row represents a unique student ID and each column represents each test item and the final grade. How can I do this without resorting to copy and transpose paste?
On your final grade file, add columns for each item #. Assuming the first item # is in cell C2, and your item analysis data is in sheet Sheet1, put the following formula in cell C2 of your grade file, validate with Ctrl+Shift+Enter (it's an array formula), then copy across and down.
=INDEX(Sheet1!$C$1:$C$5000,MATCH($A2&"|"&C$1,Sheet1!$A$1:$A$5000&"|"&Sheet1!$B$1:$B$5000,0))
The answer is with 2 steps.
First you have to change the grade letters to numbers(for Excel t make an average on the 2nd step)
I took an example of grades but you can change it as you desire.
To switch the grades use the vlookup function. lets assume your first 3 coulmns are occupied with: Student ID Item # Response and your grade table is on columns e and F then on cell d2 insert the following :
=vlookup(a2,e:f,2,0)
Now you are ready to make an average of each student. the best way to to so is by a Pivot table. Choose all of the data and click on the insert ribbon to insert a pivot table. on rows get drag the students. and columns drag the fixed grade(numbers) the only thing left to to is to change the value from count to average.
I have a spreadsheet where column P has a score between 1-6
The cell O4 has the following formula: =AVERAGEIFS(P8:P5000,P8:P5000,"<>6",P8:P5000,"<>0")
This formula searches for the average of the score in column P excluding 6, blanks and 0
Column O has staff names e.g John, Mark, Tim.......
What i want to do is for Cell O4 to automatically calculate the average of the figures shown in column P after i have used the filter function to show only results of a selected staff member.
I was hoping excel might be able to do this automatically however cell O4 appears to still be showing the average of the whole column P regardless of whether i have filtered or not.
I was given the formula below on another forum but it seems to be giving slightly wrong results albeit only by a small amount but i need to have the results exact if possible. Any help appreciated.
=SUMPRODUCT(1-ISNUMBER(MATCH(P8:P100,{0,6},0)),SUBTOTAL(9,OFFSET(P8,ROW(P8:P100)-ROW(P8),0,1)))/SUMPRODUCT(1-ISNUMBER(MATCH(P8:P100,{0,6},0)),SUBTOTAL(2,OFFSET(P8,ROW(P8:P100)-ROW(P8),0,1)))
Maybe
{=AVERAGE(IF((P8:P5000<>6)*(P8:P5000<>0)*SUBTOTAL(103,INDIRECT("O"&ROW(8:5000))),P8:P5000))}
will do what you want. Assuming the Filter is on column O.
The 103 in SUBTOTAL will also exclude if rows are manually hidden. If this ist unwanted and it should only exclude hidden rows, if filtered, then use 3 instead.
This is an array formula. Input it into the cell without the curly brackets and then press [Ctrl]+[Shift]+[Enter] to create the array formula.
I would create a separate table in a new sheet with all unique staff members and then perform the calculation. This way, you can quickly compare values for all staff just by scanning the table instead of having to constantly update the filter to see the values for potentially dozens or hundreds of staff. You would add the staff name range and criteria to your AVERAGEIFS formula.
For your example:
Sheet 2
A B
--- ---
1 | Staff Average
2 | Bob =AVERAGEIFS(Sheet1!$P$8:$P$5000,Sheet1!$O$8:$O$5000,A2,Sheet1!$P$8:$P$5000,"<>6",Sheet1!$P$8:$P$5000,"<>0")
3 | Mary =AVERAGEIFS(Sheet1!$P$8:$P$5000,Sheet1!$O$8:$O$5000,A3,Sheet1!$P$8:$P$5000,"<>6",Sheet1!$P$8:$P$5000,"<>0")
4 | Joe =AVERAGEIFS(Sheet1!$P$8:$P$5000,Sheet1!$O$8:$O$5000,A4,Sheet1!$P$8:$P$5000,"<>6",Sheet1!$P$8:$P$5000,"<>0")
Suppose we have following data
prices
leptop 30
pc 29
table 10
house 15
car 25
train 32
pen 45
dog 33
cat 17
TV 8
I have calculated average of these prices avg==AVERAGE(D3:D12) where D3:D12 are price columns. Now I want to choose these items or list items which has price less than average for example, I know there is function if, but how can I use it together to list all data, which satisfies the if condition?
Are you trying to list the prices that are less than the average all in the same cell?
If you're just trying to indicate whether they are or not next to the column, you could use: =IF(D3 < AVERAGE($D$3:$D$12), "Less Than", "Greater or Equal")
Edit:
http://i.imgur.com/SRTfvJe.png
Ok, to get the result you want (see image) then you need to use the following formulas (this assumes these formulas are in column F).
The first row in the column should be: =IF(B3 < AVERAGE($B$3:$B$6), A3, "") where B3 is the data and A3 is the name.
And all the other rows should be: =IF(B4 < AVERAGE($B$3:$B$6), IF(F3="", A4, F3 & ", " & A4), F3) where B4 is the data and A4 is the name.
This is how you could do with with Advanced Filter. Set-up your excel sheet as follows, and enter the formulas appropriately:
Then, go to Advanced Filter:
You will get:
In E3 and copied down:
=IF(D3<AVERAGE(D$3:D$12),C3,"")
will give a list (admittedly with spaces) if the names are in ColumnC. (Guessing that 'continue' does not mean the same cell.)
Does a filter work for your needs? If I go to the "data" tab in Excel 2010, highlight the data, and click "Filter", I can filter on items "below average" in the price column.
I have an excel sheet containing two columns of data that I'd like to rank.
Suppose we have the following:
A B
Franz 58
Daniel 92
Markus 37
Jörg 58
I would like a formula to rank the above data based on column B, and where there are duplicate values (Franz and Jörg) to put the alphabetical name first. What I have at the moment is simply duplicating Franz twice:
=INDEX(Name,MATCH(A2,Points,0))
Can someone advise me of formula / code that will rank the data and arrange duplicate values alphabetically?
Thanks
I would add a helper column in next to your data to help out with ties.
so in column C use
=B1+1/COUNTIF($A$1:$A$4,"<="&A1)/10
This will add on a decimal ranking system based on the name. This assumes that your numbers in column B do not have decimal places, if they do then you will need to increase the 10 on the end of the formula to account for it ie: for 2 decimal places use 1000, 3 : 10000 etc
Use this formula to get the first name
=INDEX(name,MATCH(LARGE(points,1),points,0))
adjust the 1 to 2 for the second name etc
EDIT had the sign around the wrong way
This will rank your data and will not repeat duplicates too:
In C2:
=SUM(1*(b2>$b$2:$b$5))+1+IF(ROW(b2)-ROW($b$2)=0,0,SUM(1*(b2=OFFSET($b$2,0,0,INDEX(ROW(b2)-ROW($b$2)+1,1)-1,1))))
CTRL+SHIFT+ENTER to turn it into an array
Drag these down to C5 and it will not duplicate rank where the name is the same, it will rank them alphabetically if they are the same.
Then if you wanted to order them automatically in order of top performer/score you then do this:
Putting this in E2:
=INDEX(A2:A5,MATCH(LARGE(C2:C5,ROW()-1),C2:C5,0))
...and drag down
Then use a vlookup on your data to return the score putting this in F2:
=vlookup(E2,A2:C5,2,false)
...and drag down
This should give you a table of highest scoring people in score order.
Assuming A2 is the first of the ranked points scores try this version
=INDEX(Name,SMALL(IF(A2=Points,ROW(Points)-MIN(ROW(Points))+1),COUNTIF(A$2:A2,A2)))
confirmed with CTRL+SHIFT+ENTER and copied down
Requires the Name list to be sorted because names with duplicate scores will be listed in the order shown