I want to round values to its nearest 50.
For e.g.
121 should get rounded to 100
129 should get rounded to 150
178 should get rounded to 200
165 should get rounded to 150
I have tried the following functions...
=FLOOR(C629,50)
=FLOOR((C629+50),50)
=CEILING(C631,50)
But I am still not getting the results as expected.
From the examples you have provided, it appears that you want to move each number to the nearest multiple of 50.
This function should accomplish this:
=ROUND(C629 / 50 , 0) * 50
This works in the following manner for 129:
129 / 50 = 2.58
ROUND(2.58 , 0) = 3
3 * 50 = 150
EDIT: The OP's comment to use the in-built MROUND is a much better idea.
For clarity, the simplest answer is MROUND, e.g.:
=MROUND(589,50)
This solution was submitted in a comment by shantanuo.
Related
I have a dataframe.Structure:
SEQ product_name prod_cost non-prd_cost mgmt grand_total
1 prod1 100 200 20 320
2 prod2 200 400 30 630
3 prod3 300 500 40 840
4 prod4 100 300 50 450
I want to calculate sumproduct(in excel) based on condition.The condition is based on product_name.
lets say I want to calculate a variable called
sumprod_prod1_prd_prod3_mgmt = SUMPRODUCT(SEQ 1-4,product_name='prod1'_prod_cost and 'prod3'_mgmt)/2 = 100+40=140
How can I do this in pandas?
While I am a bit confused by your question, since the excel SUMPRODUCT function returns the sum of the products of corresponding ranges or arrays, and you seem to want the SUM of a singular combination.
To get the desired value:
sumprod_prod1_prd_prod3_mgmt = df[df['product_name'] == 'prod1']['prod_cost'].values[0]+df[df['prod_name']=='prod3']['mgmt'].values[0]
This solution gives a single result for the specified values. If you need a solution which provides the same functionality as excel, please update your question and example to better define what you are looking for.
I am trying to get the percentage correct in excel giving the following example. For example, you have 2 errors, and 20 documents. 2/20 is like .05 or %5 were errors. I want how many wasn’t errors which is 95%. How do I get 95% using an equation or formula in excel. I will rate high oh for whoever can answer this!
Of course you can do your simple maths this way:
(20 - 2) / 20 = 18 / 20 which is then for a %
18 / 20 * 100 = 90%
Of course, 2 is 1/10th of 20 and therefore 10%, not 5%. Percent means "per 100" Therefore, to be formally correct, you should multiply both sides of your equation with 10, making for (2*10)/(20*10) = 0.1 = 10%
Since 2/20 = 10%, (20-2)/20 must be 90%. Alternatively, 1-(2/20) also inverts the result.
I have data in Excel in the following format:
Column A Column B
20/03/2018 300
21/03/2018 200
22/03/2018 100
23/03/2018 90
24/03/2018 300
25/03/2018 200
26/03/2018 100
27/03/2018 50
28/03/2018 90
29/03/2018 100
30/03/2018 110
31/03/2018 120
I would like to get the date where the minimum of B would never be under 99 again chronologically. It the example above, that would happen the 29th of March.
If I try to get it with: =INDEX(A:A,MATCH(99,B1:B12,-1)) the value returned is 22/03/2018 as it is the first occurrence found, searched from top to bottom.
In this case it would be perfect to be able to do a reverse match(e.g. a match that searches from bottom to top of the range) but this option is not available. I have seen that it is possible to do reverse matches with the lookup function but in that case I need to provide a value that is actually in my data set (99 would not work).
The workaround I have found is to add a third column like the following (with the minimum of the upcoming value of B going down) and index match on top it.
Column A Column B Column C
20/03/2018 300 50
21/03/2018 200 50
22/03/2018 100 50
23/03/2018 90 50
24/03/2018 300 50
25/03/2018 200 50
26/03/2018 100 50
27/03/2018 50 50
28/03/2018 90 90
29/03/2018 100 100
30/03/2018 110 110
31/03/2018 120 120
Is there a way of achieving this without a third column?
The AGGREGATE function is great for problems like these:
=AGGREGATE(14,4,(B2:B13<99)*A2:A13,1)+1
What are those numeric arguments?
14 tells the function to replicate a LARGE function
4 to ignore no values (this function can ignore error values and other things)
More info here. I checked it works below:
If your dates aren't always consecutive, you'll need to add a bit more to the function:
=INDEX(A1:A12,MATCH(AGGREGATE(14,6,(B1:B12<99)*A1:A12,1),A1:A12,0)+1)
=INDEX(A1:A12,LARGE(IF(B1:B12<=99,ROW(B1:B12)+1),1))
This is an array formula (Ctrl+Shift+Enter while still in the formula bar)
Builds an array of the row 1 below results that are less than or equal to 99. Large then returns the largest row number for index.
I have a column with ordinal values. I want to have another column that ranks them in equal groups (relatively to their value).
Example: If I have a score and I want to divide to 5 equal groups:
Score
100
90
80
70
60
50
40
30
20
10
What function do I use in the new column to get this eventually:
Score Group
100 5
90 5
80 4
70 4
60 3
50 3
40 2
30 2
20 1
10 1
Thanks! (I'm guessing the solution is somewhere in mod, row and count - but I couldn't find any good solution for this specific problem)
If you don't care about how the groups are split for groups that aren't evenly divisible, you can use this formula and drag down as far as necessary:
= FLOOR(5*(COUNTA(A:A)-COUNTA(INDEX(A:A,1):INDEX(A:A,ROW())))/COUNTA(A:A),1)+1
Possibly a more efficient solution exists, but this is the first way I thought to do it.
Obviously you'll have to change the references to the A column if you want it in a different column.
See below for working example.
I can't seem to figure out a formula in excel for rounding up or down numbers to end in either 49 or 99.
What I'm looking to do
$824 should round down to $799; $825 should round up to $849; $874 should round up to $899; $873 should round down to $849
The number should round up or down to whichever number it is closest to.
Since it's always 49 or 99 you can use MROUND like this:
=MROUND(A4,50)-1
If you have a reasonably small range and you want other unique values that are not multiples of each other you can use a build-in lookup function like this (replace 'A1' with your value or cell address):
=LOOKUP(A1, {0,575,625,675,725,775,825,875,900}, {"Too Low",599,649,699,749,799,849,899,"Over"})
The lookup function allows you to do odd rounding such as your referring to by rounding 874 up instead of down. Alter the equation like this for this offset.
=LOOKUP(A1, {0,574,625,674,725,774,825,874,900}, {"Too Low",599,649,699,749,799,849,899,"Over"})
=ROUND(A1/50,0)*50-1
Source: http://www.mrexcel.com/forum/excel-questions/24527-round-nearest-50-a.html
So essentially, just round to the nearest 50 then subtract 1.
I agree that rounding of 874 to 899 seems strange. However, if this is not a mistake and can be reasoned, for example, by desire to choose 99 in the case of a tie-break, then here is the solotion:
=IF(ABS(MROUND(A1;100)-1-A1)<=ABS(MROUND(A1;50)-1-A1);MROUND(A1;100)-1;MROUND(A1;50)-1)
Output:
824 799
825 849
873 849
874 899