If greater than multiply by result, if not don't - excel

Trying to do an if else statement, if the results of the index query is greater than the other. I want it to go like this:
If index query / index query's result is greater than 1, multiply the formula by the percentage it is greater than 1.
For example
If 10 / 5 is greater than 1, multiply it by the sum of (4 * 3), else, don't multiply it and just do the sum.
=IF(
INDEX(AK:AK,MATCH($A3,M:M,0))>INDEX(AL:AL,MATCH($A4,M:M,0)),
SUM(B12*E13*R24)*(INDEX(AK:AK,MATCH($A3,M:M,0),SUM(B12*E13*R24)))
)
not getting anywhere with this.

It seems that this can be reduced down to multiplying your base calculation by either 1 or the quotient of the two lookups when their quotient is greater than 1.
=B12*E13*R24*MAX(INDEX(AK:AK,MATCH($A3,M:M,0))/INDEX(AL:AL,MATCH($A4,M:M,0)), 1)

Related

Calculation of average based on a weighted score

I'm trying to calculate an average score based on a list of parameter scores (between 0 and 5). The trick is that I want to be able to weight each parameter.
Eg:
Parameter A Parameter B Parameter C
Weight 100% 70% 0%
Score 4 5 0
In the above example, the average score should be 3,75 as parameter c is left out.
I've tried with this formula: =IF.ERROR(SUM((A3*A5);(B3*B5);(C3*C5))/COUNTA(A3:C3);""). The formula seems to work if none of the parameters weight is equal to 0. How can I adjust the formula, so it excludes a score if weight is equal to zero?
I think it should be rather easy, I just can't get it to work.
Check this :
=SUMPRODUCT( A2:A4, B2:B4 ) / SUM( B2:B4 )
Source : https://exceljet.net/formula/weighted-average
With COUNTA you are counting the non empty cells, while you should count the non zero cells. So, assuming that the weights are in A3:C3 and the scores in A5:C5:
=IFERROR(SUMPRODUCT(A3:C3;A5*C5)/COUNTIF(A3:C3;">0");"Error: all the weigths are 0")
It would be like this:
(1*4 + 0.7*5) / 2 = 3.75
In other world the formula is:
((WeightA/100 * scoreA) + (WeightB/100 * scoreB) + (WeightC/100 * scoreC)) / 3
=SUMPRODUCT(A1:A3;B1:B3) / COUNTIF(B1:B3;"<>0") / 100
Something like this would work

origin value and after sum after ROUND() is different

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

Explain the CEILING function for dates

I have a formula which gives me different dates depending on the multiplier. I am not sure how it works though, except that it rounds a date. The formula is the following:
=DATE(YEAR($L$4),CEILING(MONTH($L$4),2),0)
So imagine today´s date is 18/08/2015 in cell L4. If i change the multiplier i get the following results:
=DATE(YEAR($L$4),CEILING(MONTH($L$4),2),0) = 31/07/2015
=DATE(YEAR($L$4),CEILING(MONTH($L$4),3),0) = 31/08/2015
=DATE(YEAR($L$4),CEILING(MONTH($L$4),4),0) = back again to 31/07/2015.
Why does this happen? Why does it go back to 31/07/2015 if the multiplier increases to 4?
=CEILING('number', 'multiple') returns a multiple of the 'multiple' that is nearest to the 'number'.
Since MONTH evaluates to 8 or August, you would have =CEILING(8, 3), which evaluates to 9, because 9 is the multiple of 3 closest to 8. 2 and 4 as multiples will both return 8.
=DATE(2015, 9, 0) will return the last date of the previous month, because the day is 0.
If you tried your formula with CEILING(MONTH($L$4), 10), you would get 31/9/2015, because the multiple of 10 nearest to 8 is 10, and the DATE formula will end up looking like =DATE(2015, 10, 0) which evaluates to 31/9/2015.
As a side note, the button below is very helpful in analyzing the formulas that you select in the excel chart.

Sum minimum of corresponding column values - limited to date range

I have a data set with four columns: Start Date, End Date, Scheduled Qty, and Actual Quantity:
Start Date End Date Scheduled Qty Actual Qty
04/13/15 04/17/15 35 19
04/20/15 04/24/15 35 42
04/27/15 05/01/15 35 41
05/04/15 05/08/15 35 41
I want to find the total actual, except when the actual exceeds the scheduled I want to used the scheduled number.
In an already answered question (Sum minimum of corresponding column values) I found an array formula that works to total the lesser values of each row for the Qty columns (quotes used to display the less than symbol):
=SUM(IF(C1:C4"<"D1:D4, C1:C4, D1:D4))
This gives me a total for my whole range, but now I'd like to limit it to a date range such as end dates within a given month. I've used SUMIFS in other situations to look at my end dates and only sum data that falls within a given month, but I'm not figuring out how to combine that idea with the one from the array formula.
Any ideas how to make this happen? I'm working in Excel 2013.
Here's an extension of chancea's approach:
Excel's SUM function (and AVERAGE, STDEV, etc.) have the useful behavior of "skipping" over text values. For example AVERAGE(3, 4, "dog", 5) returns 4. You can leverage this behavior nested IF's inside a sum. For instance,
=SUM(IF(MONTH(B1:B4)=4,IF(C1:C4<D1:D4,C1:C4,D1:D4),"NO"))
will sum
(a) the lesser of scheduled and actual
(b) when the month is 4
This is accomplished by nested IF's. The outer IF is
IF(MONTH(B1:B4)=4,...,"NO") [if month <> 4, IF returns text ("NO"), which SUM skips]
The inner IF is the same one that chancea showed.
You can nest as many tests/filters for your data as you need
To add criteria onto an array function most of the time you are just going to be multiplying the extra condition onto whatever set of conditions you already have.
The reason why this works is simply because we start with our list of numbers we want to sum:
IF(C1:C4<D1:D4, C1:C4, D1:D4) => { 19, 35, 35, 35 }
Then we multiply 1's or 0's to each of the values that meet the extra criteria.
So for an example lets say that we only want to check the quantity of values that have an end date within the month of 4. We can do that with:
MONTH(B1:B4)=4
Just multiply that criteria in the SUM function to basically create a boolean and condition for that criteria:
=SUM(IF(C1:C4<D1:D4, C1:C4, D1:D4)*(MONTH(B1:B4)=4))
= SUM({ 19, 35, 35, 35 } * { 1, 1, 0, 0}) => SUM( {19, 35, 0, 0} ) = 54
This is the same if we want to add n condition's:
=SUM(IF(C1:C4<D1:D4, C1:C4, D1:D4)*(MONTH(B1:B4)=4)*(`Condition2`)*(`Condition3`)...)
You can use any formula or operator that returns a true/false value within your conditions.
Such as: = > < >= <= <> IF(...,TRUE)
To add OR logic as a criteria you need to use addition instead of multiplication and then group them inside a (..)>0 like this:
(((Or_Condition1)+(Or_condition2)+...+(Or_conditionN))>0)
So if we wanted to sum months 4 OR 5 we can write:
=SUM(IF(C1:C4<D1:D4, C1:C4, D1:D4)*(((MONTH(B1:B4)=4)+(MONTH(B1:B4)=5))>0))

Excel Formula to SUMIF date falls in particular month

I have excel data in following format.
Date Amount
03-Jan-13 430.00
25-Jan-13 96.00
10-Jan-13 440.00
28-Feb-13 72.10
28-Feb-13 72.30
I need to sum the amount field only if the month lies in Jan Month.
What i have tried is ,
=SUMIF(A2:A6,"MONTH(A2:A6)=1",B2:B6)
But it returns,
0
What i need is,
Following values to be summed, 430.00 + 96.00 + 440.00 = 966.00
Try this instead:
=SUM(IF(MONTH($A$2:$A$6)=1,$B$2:$B$6,0))
It's an array formula, so you will need to enter it with the Control-Shift-Enter key combination.
Here's how the formula works.
MONTH($A$2:$A$6) creates an array of numeric values of the month for the dates in A2:A6, that is, {1, 1, 1, 2, 2}.
Then the comparison {1, 1, 1, 2, 2}= 1 produces the array {TRUE, TRUE, TRUE, FALSE, FALSE}, which comprises the condition for the IF statement.
The IF statement then returns an array of values, with {430, 96, 400.. for the values of the sum ranges where the month value equals 1 and ..0,0} where the month value does not equal 1.
That array {430, 96, 400, 0, 0} is then summed to get the answer you are looking for.
This is essentially equivalent to what the SUMIF and SUMIFs functions do. However, neither of those functions support the kind of calculation you tried to include in the conditional.
It's also possible to drop the IF completely. Since TRUE and FALSE can also be treated as 1 and 0, this formula--=SUM((MONTH($A$2:$A$6)=1)*$B$2:$B$6)--also works.
Heads up: This does not work in Google Spreadsheets
=Sumifs(B:B,A:A,">=1/1/2013",A:A,"<=1/31/2013")
The beauty of this formula is you can add more data to columns A and B and it will just recalculate.
=SUMPRODUCT( (MONTH($A$2:$A$6)=1) * ($B$2:$B$6) )
Explanation:
(MONTH($A$2:$A$6)=1) creates an array of 1 and 0, it's 1 when the
month is january, thus in your example the returned array would be [1, 1, 1, 0, 0]
SUMPRODUCT first multiplies each value of the array created in the above step with values of the array ($B$2:$B$6), then it sums them. Hence in
your example it does this: (1 * 430) + (1 * 96) + (1 * 440) + (0 * 72.10) + (0 * 72.30)
This works also in OpenOffice and Google Spreadsheets

Resources