I'm trying to write a code in Excel that basically counts multiplies valueA by 5 when ValueA<=15. Once valueA surpasses 15 (therefore ValueA>15), it will the multiply ValueA by 9 for the remaining amount value. For example, if ValueA=20, 1-15 will be multiplied by 5, and the 16-20 will be multiplied by 9, to give the total amount.
Can anybody else out with this?
So far, I have:
=IF(AND(A2="LR",B2<=15),B2*5, IF(AND(A2="LR",B2>16....
not sure how to finish off!
=IF(AND(A2="LR",B2<=15),B2*5, IF(AND(A2="LR",B2>15),B2*9-75, ... Whatever value you want if A2 doesn't equal LR))
Related
I have a data set something like this
Units Price
1 15
100 10
150 9
200 8
50000 7
I need the output as Price with respect to quantity.
Example- If Input value is 90 it should give price as 15
If input is 210 it should give value as 8.
However,sadly I cannot use IF statement.
Thanks in advance.
You can use a combination of INDEX and MATCH
=INDEX(B1:B5,MATCH(lookup_value,A1:A5,1))
This assumes Units are in column A and Price is in column B
Make sure you understand both functions:
INDEX
MATCH - particularly the reason for the ,1) at the end
You can also use VLOOKUP. This is probably a bit easier although INDEX/MATCH is more versatile:-
=VLOOKUP(Lookup_value,$A$2:$B$6,2,TRUE)
I have a rather big (long) table and need to do something quite simple but I'm currently with a sort of blackout...
Imagine that you have:
Date 1 Value 1 Date 2 Value 2 Date 3 Value 3 Date of MAX
... ... ... ... ... ... ????
I want to deploy in ???? a formula that will result in the date at which the maximal value (between Value 1...3) was registered. For instance:
Date 1 Value 1 Date 2 Value 2 Date 3 Value 3 Date of MAX
20160501 10 20160722 47 20161002 9 20160722
meaning, the Date of MAX is of Date 2 because that was the date at which the MAX was measured.
Thanks in advance.
You could do a more general solution using offset:-
=MAX(N(OFFSET(D2,0,COLUMN(A:D)*3)))
to find the largest value - put this in (say) R2.
Then find a match for it and pick out the corresponding date:-
=OFFSET(C2,0,MATCH(R2,N(OFFSET(D2,0,COLUMN(A:D)*3)),0)*3)
assuming the dates and values are every third column.
These are array formulae and must be entered with CtrlShiftEnter
If the last value really was in P21 you would have to give a row offset as well as a column offset.
OK, I found a dirty but simple solution (don't know why I didn't think of it at first):
=IF(G2>=MAX(G2,J2,M2,P21),F2,IF(J2>=MAX(G2,J2,M2,P21),I2,IF(M2>=MAX(G2,J2,M2,P21),L2,O2)))
where the pairs (4 of them) are at FG, IJ, LM, OP. Not elegant but does the job.
I have a table with "ordered amount", "percentages", and "total sum". Note that "ordered amount" and "total sum" should be the same.
column F= sum of C:F
*rows 4,6,8,10 used =round()
As shown in the table(image), for some numbers, value in F is not the same as A when it should be. (e.g. A6(105) and F7(104), -1 after rounding).
Is there anyway to avoid this?
Thank you very much.
If the sum of the decimal points adds up to > 5, your final rounded number will round up. If they add up to < 5, the final number will round down.
Consider this example:
10.5 + 5 = 15.5, which rounds to 16.
However
10 + 5 = 15
This is what is happening in your table.
In order to get the sum of rounded numbers to add up to the same as the sum of the numbers, in your example, you will need to NOT round, but rather subtract, one of the values. I would suggest altering the largest value, as it would seem to have the least effect on the percentages, but that is a choice you can make.
To do that, with your data in row 8, for example you could do the following.
A9: =IF(B$8=MAX($B$8:$E$8),SUM($B$8:$E$8)-SUM(ROUND($B$8:$E$8,0))+ROUND(B$8,0),ROUND(B$8,0))
entered as an array formula with ctrl+shift+enter and fill right to E9.
This would give a sum of 344 which is the same as F8
I'm trying to design an excel formula for some golf game scores. Golfers get points based on a random number (0-9) and the last digit of their score. So, if the random number is 0 and the golfers score ends in 0, they get 10 points. Still with a 0 random number, if the golfers score ends in a 1, they get 9 points. 8 points for a last digit of 2. 7 for 3. 6 for 4. 10 for 5. 9 for 6. 8 for 7. 7 for 8. 6 for 9.
Score ends in: Points:
0 10
1 9
2 8
3 7
4 6
5 10
6 9
7 8
8 7
9 6
As long as I come up with one formula for the random number of 0, I can adjust it for the remaining 9 random numbers.
The way I was hoping for this to work was to just be able to enter the scores into one column and then have the points calculated in a separate column. There will also have to be a cell where I enter the random number.
Any help is appreciated!
You can use something like this to get the score if the random number is 0:
=IF(A1=0,10-MOD(RIGHT(B1),5))
This will give the points you mentioned provided:
A1 is the cell containing the random number
B1 is the cell containing the points of the golfer.
The main formula here is:
10-MOD(RIGHT(B1),5)
RIGHT() takes the last digit of the points. MOD(,5) will get the remainder when this digit is divided by 5.
When you have 0, you get no remainder, hence 0.
When you have 1, you get a remainder of 1, hence 1.
When you have 2, you get a remainder of 2, hence 2.
When you have 6, you get a remainder of 1, hence 1 again.
Then 10 minus that remainder gives you the points you're looking for.
You could certainly use =RAND()*10to get a random value in excel. Or to get a value without commas use = ROUNDDOWN(RAND()*10;0)
Then you add something a VLOOKUPto get a value to each players score. RIGHT(A1;1)gives you the last value of a field.
VLOOKUPrequires you to have a table somewhere with the values for each score as you described.
edit: the MOD solution looks even better. Please note that RANDOM gets a fresh value everytime you refresh the XLS sheet. so probably use it to get a value and put that into another field manually.
I have a spreadsheet program which rolls twenty-sided dice. Sheet 1 is Rolls and Sheet 2 is Values.
I want to roll a d20, but if it comes up 2-7, fudge it and assume I got 8 instead.
Rolls!A2's function is =RANDBETWEEN(1,20) which returns a random number between 1 and 20 to represent the d20 roll. Values!7E is function which calculates a (non-random) number (currently 13).
Currently, Rolls!C7's function attempts to calculate my result with =Values!E7+Rolls!A2. But I would like to update Rolls!C7 to reflect the fudging. If Rolls!A2 returns numbers 2, 3, 4, 5, 6, or 7, Rolls!C7 would instead be calculated as if it rolled an 8.
Replace Rolls!A2 in your formula with this: IF(AND(Rolls!A2<8, Rolls!A2>1),8,Rolls!A2) this way it will always be at least 8 unless a 1 is rolled.
Or you could do =IF(Rolls!A2=1,1,MAX(Rolls!A2,8))