Concatenate the shortcut st, nd, rd to column value - Excel - excel

Column A has numbers from 1 - 5 and in column B i want to concatenate the number of Column A with the relevant nth term as indicated in the image below. Any help will be greatly appreciate!

Without using VBA, your best option would be the "CHOOSE()" function.
Try something like this for any number > 0:
=IF(AND(MOD(ABS(A1),100)>10,MOD(ABS(A1),100)<14),"th",CHOOSE(MOD(ABS(A1),10)+1,"th","st","nd","rd","th","th","th","th","th","th"))

You can set up a named "key" separately, much like the table you are showing, and then reference the key to replace any number with the desired output.
You can then indexmatch/vlookup the number, referencing the table, to find the output.
For ex:
=vlookup($A1,key,2,FALSE)

you could use nested IF functions and RIGHT like this
=IF(OR(RIGHT(H2,2)="11",RIGHT(H2,2)="12",RIGHT(H2,2)="13"),CONCAT(H2,"th"),IF(RIGHT(H2,1)="1",CONCAT(H2,"st"),IF(RIGHT(H2,1)="2",CONCAT(H2,"nd"),IF(RIGHT(H2,1)="3",CONCAT(H2,"rd"),CONCAT(H2,"th")))))
Probably not the fastest performance wise

Related

Creating a variable if key term appears in text

I am trying to create a variable "thromboembolism death", 0 if it is not the cause of death, 1 if it is.
Is there any way to sort through this data set through spss / excel in order to create a new variable if one of the key terms e.g (DVT, Pulmonary embolism, thromboembolism) appear in the line of text? Here is what my data looks like right now.
https://i.stack.imgur.com/WDrBs.png
Also the data set is very large. 250000+ cases. I am new to data analysis, thanks for the help!
In SPSS, assuming you have a variable named death_cause with description verbatims:
COMPUTE thromboembolism_death = (INDEX(UPCASE(death_cause),'DVT') > 0)
OR (INDEX(UPCASE(death_cause),'PULMONARY EMBOLISM') > 0)
OR (INDEX(UPCASE(death_cause),'THROMBOEMBOLISM') > 0).
EXE .
In Excel, you could take a similar approach. Assuming your text verbatims are in column A:
=IF(OR(ISNUMBER(SEARCH("DVT",A1)),ISNUMBER(SEARCH("PULMONARY EMBOLISM",A1)),ISNUMBER(SEARCH("THROMBOEMBOLISM",A1))),1,0)
Alternatively, if you're comfortable using SUMPRODUCT(), the formula gets a bit shorter. Assuming you list your "strings to search for" in cells C2:C5:
=SUMPRODUCT(--ISNUMBER(SEARCH(C2:C5,A1)))>0
Note that all of the above options are case-insensitive.

Top 10 values in excel

enter image description hereenter image description here
According to given data table, I want to find out the top 10 students on the basis of marks (by using excel query) but I think Max function is not working here. kindly suggest.
You can use Large with Match and Index to get the list:-
See the image of my example. I have used dummy values.
Step1 :- Use this formula (I have used in D column 'Top 10')
=INDEX($A$2:$B$13,MATCH(LARGE($B$2:$B$13,ROW(1:1)),$B$2:$B$13,0),1)
Step2:- Then drag this formula down for 10 rows. You will get the top 10.
Let me know if you have any questions
Try the rank functions.The original RANK has been deprecated. You can use RANK.EQ instead.
The syntax is
=RANK.EQ(value, entireRangeOfValues).
e.g. =RANK.EQ(J2,$J$2:$J$8015,0)
The last parameter allows you to specify sort order.
Depending on your needs you can also look at RANK.AVG
These differ in how they rank duplicate values.

Sort AlphaNumeric with structured references in Excel

I Have an Excel Sheet with data that looks like that.
Data
x=1.1
x=11.2
x=10.3
x=1.4
x=2.5;2.6
x=2.1
x=4.7
x=6.8
x=6.2;6.3
x=1.10
What i want to do is, to sort the List that it Looks like that.
DataSort
x=1.1
x=1.4
x=1.10
x=2.1
x=2.5;2.6
x=4.7
x=6.2;6.3
x=6.8
x=10.3
x=11.2
I tried to do that with that Formula
=LEFT(Tabelle1[[#this row];[Data]];2) & TEXT(SUBSTITUTE(Tabelle1[[#this row];[Data]];LEFT(Tabelle1[[#this row];[Data]];2);"");"#0.0#")
But that did not work.
Can someone give me a hint to the right Direction?
Copy the data into a new column say B
If you are using excel 2007 or higher, go to data tab --> text to columns option after selecting your data in B
Here you can choose delimited and it will separate your data into 2 columns.
Then apply the sorting based on this column
In an unused column to the right, use this formula starting in row 2,
=LEFT(A2, 2)&TEXT(--MID(A2, 3, FIND(".", A2&".")-3), "000;#")&TEXT(--MID(A2, FIND(".", A2&".")+1, 99), "000;#")
Fill down as necessary then sort conventionally using the helper column as the primary sort key.
        
If you put a 0 prior to the numbers, that would take care of it.
X=01.1
Or, in a convoluted way, split the column as recommended above, sort the way you want and then reassemble. I would also create a column with the right 1-n sequence, just in case I need to sort in a particular way, but the come back to the original sort.
The Solution to the Problem is:
=LEFT(IF(ISNUMBER(SEARCH(";";A1));LEFT(A1;FIND(";";A1;1)-1);A1);2)&TEXT(--MID(IF(ISNUMBER(SEARCH(";";A1));LEFT(A1;FIND(";";A1;1)-1);A1);3;FIND(".";IF(ISNUMBER(SEARCH(";";A1));LEFT(A1;FIND(";";A1;1)-1);A1)&".")-3);"000;#") &TEXT(--MID(IF(ISNUMBER(SEARCH(";";A1));LEFT(A1;FIND(";";A1;1)-1);A1);FIND(".";IF(ISNUMBER(SEARCH(";";A1));LEFT(A1;FIND(";";A1;1)-1);A1)&".")+1;99);"000;#")

Converting letters to text and back again (Excel 2013)

For a piece of coursework I have to complete a register of student grades. I am trying to calculate their overall grades by converting their grades from each of the four units into numbers (which I have done using the VLOOKUP function), but I need to then convert the result of the average back into a letter. I have used VLOOKUP and also a long nested IF statement to try and accomplish this, but no matter what I can never get a valid result. This is what I have so far (this is just a link to my image as I am unable to post one).
I have converted the Target grade into a number using the formula:
=VLOOKUP(D3,'Grade Values'!A$2:B$11,2,FALSE)
Then added up the total of the different grades from the four units using this formula:
=SUM(VLOOKUP(F3,'Grade Values'!A$1:B$11,2,FALSE)+
VLOOKUP(Dashboard!G3,'Grade Values'!A$1:B$11,2,FALSE)+
VLOOKUP(Dashboard!H3,'Grade Values'!A$1:B$11,2,FALSE)+
VLOOKUP(Dashboard!I3,'Grade Values'!A$1:B$11,2,FALSE))
And then averaged it out with this: =J3/4
The problem I am facing at the moment is that when converting this number back to a letter using the same table as in the second screenshot I get an N/A result when I use this formula: =VLOOKUP(K3,Dashboard!A1:B10,1,FALSE)
I can't seem to figure out what's going wrong with the formula at the end. If anyone can please help me figure this out I will appreciate it a lot. Thank you :)
Edit: I apologise for the irrelevant tags, as far as I was aware formulas in Excel were written in JavaScript.
Personally, I would convert the letter grade to ASCII character using the function:
CODE(A1)
use the ASCII Reference Chart for the integer value of each Upper Case character. Note: A=65, B=66, etc... Perform your calculations, then you can use the function:
CHAR(A2)
to convert the number back into a character.
Example:
A1="A"
A2="B"
A3="C"
B1="=CHAR(AVERAGE(CODE(A1),CODE(A2),CODE(A3)))"
just copy the column A in the sheet dashboard and paste it in column C in the sheet dashboard... so you have
A B C
A* 7 A*
A 7 A
B 6 B
....
the formula you have to use is
=VLOOKUP(K3,Dashboard!$B$1:$C$10,2,FALSE)
remember that this time u need to match a number... not a letter

Maximum level of nesting reached in IF Statement

I am using the following IF statement in Excel:
=IF(W41="Please Select",0,IF(W41="Plant Hire","XPH",IF(W41="Plant Sales","SPH",IF(W41="Crane Hire","XCH",IF(W41="Crane Sales","SCS",IF(W41="General X-Hire","GXH",IF(W41="Operations","XOP",IF(W41="Goods / Services","GSE",0))))))))
However it won't let me add any more IFs as it is telling me I have reached the maximum allowed. I need to add another six like so:
IF(W41="Plant","XPL",IF(W41="Whale","SWFM",IF(W41="Fire","FTH", etc
Please can someone show me what I would need to do to complete the formula?
This would be easier to do with a lookup table. List all the possible W41 values in column Y and all the corresponding codes in the same row in column Z then use this formula
=IFERROR(VLOOKUP(W41,Y:Z,2,0),0)

Resources