Excel: How to show rank increment with + & - sign? - excel

I am preparing a keyword ranking excel sheet.
To show rank change i am using simple subtraction i.e. 94 (previous ranking) - 74 (current ranking) = 20 (improvement).
Issue 1: Because the ranking has gone up i need to show +20.
Issue 2: for keyword that was not having ranking i am using 0.
0 (no ranking) - 54 (current ranking) = -54
how to show +54?

You can use
=IF(A1<>0,A1-B1,B1)
EDIT : 1
=TEXT(IF(A1<>0,A1-B1,B1),"+0;-0;0")
See image for reference.
EDIT 2 :
=IF(AND(A2<>0,B2<>0),TEXT(A2-B2,"+0;-0;0"),IF(A2=0,"+" & B2,"-" & A2))
Conditional Formatting:
You'll have to create two conditional formatting rules for Column C.
For negative numbers - =LEFT(C1,1)="-"
For positive numbers - =LEFT(C1,1)="+"
Follow following steps:
Select Column C
Click the Home tab and from the Conditional Formatting drop down (in the Styles group), choose New Rule
Choose the Use A Formula To Determine Which Cells To Format option from the upper pane
Enter =LEFT(C1,1)="+" in formula box (This is for positive numbers)
Click Format and then click the Fill tab
Choose a color from the palette (Choose green as you mentioned in comments)
Click OK twice
Repeat same steps for negative numbers except that the formula should be =LEFT(C1,1)="-" and in formatting select red color.

Suppose you have the following table:
Previous | Current
94 | 74
0 | 54
74 | 94
and put =IF(A2=0;CONCATENATE("+ ";B2);CONCATENATE(IF(A2-B2>0;"+ ";"- ");ABS(A2-B2))) into column C, than your result will be:
Previous | Current | Rank
94 | 74 | + 20
0 | 54 | + 54
74 | 94 | - 20

Related

Search date between two cells and return a third cell value

I Have two separate tables:
Start End Number
12/10/2017 31/10/2019 4
1/11/2019 28/02/2020 5
1/03/2020 1/12/2025 6
Also
Value Date Multiplication
45 1/11/2017
124 1/04/2018
43 1/09/2018
123 1/02/2019
46 1/07/2019
76 1/12/2019
789 1/05/2020
I want the Multiplication column to be populated by Value * Number based on if the date is between Stand and End
e.g.
Since 1/11/2017 is between 12/10/2017 & 31/10/2019 the values should be , 45*4.
According with the following sample data image, try this in H2:
=F2*VLOOKUP(G2, A$2:C$4, 3, TRUE)
Fill down as necessary.

Order of formula calculation in Excel 2016

I would like to use the result of a formula A in another cell that is a part of the formula A and avoid circular reference. Also, iterative calculation doesn't sound like what I need.
Lets say I have a table with a single column of which each cell uses a formula that evaluates the state of the whole table and it does so from the top most cell to the bottom.
For example, formula is =XXX+SUM($A$1:$A$4) where XXX is the content of each cell and the table looks like this initially:
A
--
1 | 3
2 | 5
3 | 1
4 | 6
Lets say I have a trigger for calculation start and the first cell starts calculation:
A1 is now 3 + (3+5+1+6) = 18
after that A2 starts calculation and A2 is now 5 + (18 + 5 + 1 + 6) = 35
after that A3 starts calculation and A3 is now 1 + (18 + 35 + 1 + 6) = 61
after that A4 starts calculation and A3 is now 6 + (18 + 35 + 61 + 6) = 126
So the final table would look like this:
A
--
1 | 18
2 | 35
3 | 61
4 | 126
Please understand that this is a simplified example, I am aware this calculation can be optimized but that is not what I need.
Is there a way to avoid VBA?
Only VBA will allow you to avoid hitting the circular reference problem.
If you are prepared to separate your output from your input then you can use Excel to replicate the calculation steps or with a bit of analysis you can simplify the calculation steps (though I suspect this is what you term as optimizing). Picture below shows both

Return max index value in vlookup

I'm trying to pair a vlookup with a max function. For some reason it only returns #ref every time I try to use it though.
My sheet looks like this:
A - B - C - D - E - F - G
1...
5 - Prod5 id1 $100 $125 $155 $110 $150
6...
A:G is named buyAverages
C:G is named buyAveragesPrices
What I want to do is have a vlookup go and find a value in Col A and then return the highest value in that Col. So example:
A - B
1 - Prod5 *return highest price for Prod5
What I wrote in B1, which failed:
VLOOKUP(A1,buyAverages,MAX(buyAveragesPrices))
So how do I achieve this lookup? Everything I have found is how to use MAX for the lookup value, but nothing to use max on the returned index.
Try this
=MAX(IF(A:A="Prod1",C:G))
This is an Array Formula. i.e you have to press Ctrl+Shift+Enter
If there's only one instance of each Product then you can use INDEX/MATCH like this
=MAX(INDEX(C2:G100,MATCH("Prod 1",A2:A100,0),0))
Longer than Sid's suggestion but doesn't need CSE and might be more efficient if you only have a single match
If you have that formula in Z2, for example, you can use this version to get the location from row 1
=INDEX(C1:G1,MATCH(Z2,INDEX(C2:G100,MATCH("Prod 1",A2:A100,0),0),0))
You can have all in one cell using Vlookup and Max with a nested formula. For example at the top of the page:
A1 = Select the name of the product you want to find the max
A2= MAX(BUSCARV($A$1;$A$3:$F$11;3;FALSO);BUSCARV($A$1;$A$3:$F$11;4;FALSO)
;BUSCARV($A$1;$A$3:$F$11;5;FALSO);BUSCARV($A$1;$A$3:$F$11;6;FALSO))
It's long but you only have to type it once. With this formula we get all the different amounts in each column and then we ask for the maximum. It works if all the products are different. Change the name of the product and you'll find the MAX in the table.
Example Prod8
Prod8 41 ; If we change and you select in A1 Prod4 you'll
get 70 and so on..
Prod1 id1 100 125 155 110
Prod2 50 25 20 75
Prod3 60 65 15 90
Prod4 70 12 50 43
Prod5 100 200 80 25
Prod6 20 28 40 40
Prod7 14 43 60 80
Prod8 22 33 15 41
Prod9 65 48 50 70
Select your range accordingly.
You also could include in A1 a match code to select the name of your products..

Ranking in Excel, when I want the top n I get the top n+1 (or n+x)

I have a list in excel and I'd like it to select the higher 3 results, and only 3. It seems easy to do with conditional formatting in this example:
1 | 2 | 3 | 4 | 5 | 6
44 | 78 | 98 | 45 | 52 | 98
Where the 2nd, 3rd and 6th number will be highlighted.
The problem appears with something like this:
1 | 2 | 3 | 4 | 5 | 6
44 | 78 | 78 | 45 | 87 | 98
Excel will highlight the 2nd, 3rd, 5th and 6th number, because the first two (the third on a sorted list) are equal.
How can I make Excel select only one of them?
(the solution doesn't need to use conditional formatting, any tools available on Excel can be used, from formulas to VB, but simplicity it's desirable).
for your conditional formatting, we need to break the tie. One way to do this is to count the number of times a value appears in the previous comparisons.
This would change your conditional formula to
=(RANK(A2,$A$2:$F$2)+COUNTIF($A$2:A$2,A2)-1)<=3
Note that absolute positions are used in some cases, and relative in others.
Breakdown:
RANK(A2,$A$2:$F$2) - Rank formula. You know this one, as you're using it now
COUNTIF($A$2:A$2,A2) - count the number of times the value appears - note that the reference does not have a $ in front of the A after the colon - this is to ensure that the range gets bigger as we process the formula along the row (1st count: A2:A2, 2nd count: A2:B2, etc)
-1 - as the count will always match one number (itself)
so, for your second example,
44 78 78 45 87 98
The new ranks are
6 3 4 5 2 1
and the formulas convert to
=RANK(A2,$A$2:$F$2)+COUNTIF($A$2:A$2,A2)-1
=RANK(B2,$A$2:$F$2)+COUNTIF($A$2:B$2,B2)-1
=RANK(C2,$A$2:$F$2)+COUNTIF($A$2:C$2,C2)-1
=RANK(D2,$A$2:$F$2)+COUNTIF($A$2:D$2,D2)-1
=RANK(E2,$A$2:$F$2)+COUNTIF($A$2:E$2,E2)-1
=RANK(F2,$A$2:$F$2)+COUNTIF($A$2:F$2,F2)-1
for the conditional formatting
I couldn't think of one cell solution, but here is my take with a helper column:
Rank_Row column, check if the Input is duplicated, if yes then add fraction of row number. C2=IF(COUNTIF($B$2:$B$7,B2)>1,RANK(B2,$B$2:$B$7)+ROW()/100,RANK(B2,$B$2:$B$7))
Filter column is using simple RANK in ascending order, you can use this column to filter top 3. D2=RANK(C2,$C$2:$C$7,1)
Drag down the both formulas to copy down.

Excel nesting error

I'm using Excel 2013 and I have had to create a If statement which basically chooses a student's grade depending on a certain mark number (obviously, nesting is needed) Here is the If statement I created:
=IF(E2<=20,"N",
IF(OR(E2>=21,E2<=25),4,
IF(OR(E2>=26,E2<=32),"5C",
IF(OR(E2>=33,E2<=38),"5B",
IF(OR(E2>=39, E2<=44), "5A",
IF(OR(E2>=45, E2<=53), "6C",
IF(OR(E2>=54, E2<=61), "6B",
IF(OR(E2>=62, E2<=71), "6A",
IF(OR(E2>=72, E2<=87), "7C",
IF(OR(E2>=88, E2<=103), "7B",
IF(OR(E2>=104, E2<=120), "7A")))))))))))
The error I receive is:
the specified formula cannot be entered because it uses more levels of nesting than allowed in the current file format
My question is, how do I shorten this statement to allow Excel to use it?
Place the logic in the spreadsheet cells. One column for the minimum score, and one column for the grade-:
A B
1 0 N
2 21 4
3 26 5C
4 33 5B
5 39 5A
6 45 6C
7 54 6B
8 72 7C
9 88 7B
10 104 7A
Then do a vlookup to get the grade from the actual score. vlookup will find the highest value in the A column that is less that the lookup value of 38.
In the example vlookup below 38 is the score, A1:B10 is the lookup table 2 is the 2nd column (in this case the B column) that contains the result (the grade).
=VLOOKUP(38, A1:B3, 2, TRUE)
You can also use the following formula.
=LOOKUP(E2;{0;21;26;33;39;45;54;62;72;88;104;121};{"N";4;"5C";"5B";"5A";"6C";"6B";"6A";"7C";"7B";"7C";"No match"})
There are a few different solutions. AND agreements using OR instead of the first that comes to mind.
=IF(E2<=20,"N",
IF(AND(E2>=21,E2<=25),4,
IF(AND(E2>=26,E2<=32),"5C", ...
The best way, in my opinion, is to write a UDF. Then you can use VBA and a CASE statement.
Experiment with this code in VBA to create a UDF named GRADE() - just type it into a MODULE in the VBE:
Function Grade(Marks)
Dim Score As Integer
Score = Marks * 1
Select Case Score
Case 1 To 20
Grade = "N"
Case 21 To 50
Grade = "C"
Case 51 To 90
Grade = "B"
Case 91 To 120
Grade = "A"
End Select
End Function
Then use the Function GRADE() as you would any other function but type the address of the argument - like this GRADE(B7) to use it
=+IF(O3="Negative","Negative",IF(P3="Negative","Negative",IF(Q3="Negative","Negative",IF(R3="Negative","Negative",IF(O3="Refer","Refer",IF(P3="Refer","Refer",IF(Q3="Refer","Refer",IF(R3="Refer","Refer","Positive"))))))))
I find the final status in 4 cells have positive,negative,refer,pending or blank

Resources