Excel formula to find Max and return a column from the matching row - excel

My data looks some thing like this:
Product 1
Date
Site1_Sales
Site2_Sales
Site2_Sales
x1
1-Jan
100
200
300
x2
2-Jan
60
51
150
X1
2- Jan
110
30
40
There will be 1000s of rows with repeated Product but with unique dates. This is what I would like to find:
What was the Max sales for a product ? and on which date ? I tried using Maxifs but it ends up with value error it looks it can handle only continuous ranges.
What was the sum of sales for a product for specific period e.g first 10 days ?
Any help is really appreciated. Thank you

see “Remarks” about #value error:
https://support.microsoft.com/en-us/office/maxifs-function-dfd611e6-da2c-488a-919b-9b6376b28883
SUMIF works in the same way as MAXIF (e.g. you could use a start date and end date as multiple criteria)
FILTER should help you to find the date(s) of max. Sales as well

Related

Excel Average Calculation of a Moving Criteria Range

I need to create a logic excel formula that calculates the average of 3 months prior to a specified start date. There are multiple start dates. For instance:
For ID 1, The Start Date is May-2021. I would need for the logic to calculate the average between Feb-2021 to Apr-2021 to get 91.67. For ID 2, the Start Date is Jun-2021, so I would need to calculate the average of Mar-2021 to May 2021 to get 108.33. I also would need to calculate the average of 6 months prior in a separate column.
ID
Start Date
Calculation Result
Jan-2021
Feb-2021
Mar-2021
Apr-2021
May-2021
Jun-2021
1
May-2021
91.67
50
100
75
100
25
0
2
Jun-2021
108.33
0
25
100
175
50
125
3
Apr-2021
83.33
100
150
0
75
0
200
Any help is greatly appreciated! (Not opposed to VBA suggestions either)
use INDEX to create the range.
=AVERAGE(INDEX(D2:I2,MATCH(B2,$D$1:$I$1,0)-3):INDEX(D2:I2,MATCH(B2,$D$1:$I$1,0)-1))
Or if they are true dates we can use AverageIfs:
=AVERAGEIFS(D2:I2,$D$1:$I$1,">"&EOMONTH(B2,-4),$D$1:$I$1,"<="&EOMONTH(B2,-1))

Excel formula that returns sum based on categorical and date data from 2 columns?

I have a dataset in excel that looks like this:
Supplier Date QTY
A 03/02/2018 10
A 05/01/2018 15
A 08/06/2018 30
B 02/01/2018 20
B 04/01/2018 50
B 08/01/2018 40
B 08/15/2018 50
B 10/01/2018 60
C 03/09/2018 25
C 04/08/2018 25
C 05/20/2018 25
And I want to make a spreadsheet that allows the user to enter start and end dates and the Supplier name and be able to see a total quantity of items received in that time period from that supplier.
I've tried using a combination of VLOOKUP and SUM, but I've only been able to get the first result of the quantity associated with that supplier to return. I understand that this is the nature of VLOOKUP--to only return one value. I'm pretty new to Excel so I just don't really even know which function(s) would be best to use in this scenario.
Example Output:
Enter Supplier: "B"
Enter Start Date: "03/01/2018"
Enter End Date: "09/01/2018"
Items Received: 140
Try:
=SUMPRODUCT((A2:A12=F1)*(B2:B12>=F2)*(B2:B12<=F3)*(C2:C12))
Result:

Excel formula for greater than but less than with several tiers

I have a few hundred rows of data, and each has a number between 1 and 200, and I'd like to put them in categories of 1-5 depending on where that number is.
The categories look like this:
Zones Min Max
1 0 35
2 35 60
3 60 85
4 85 110
5 110 200
I want to assign it a Zone if it is greater than the Min, but less than the Max.
I have 2 formulas I've been working with to solve it. One is a nested IF AND statement:
=IF(A1<=35,1,IF(AND(A1<=60,A1>35),2,IF(AND(A1<=85,A1>60),3,IF(AND(A1<=110,A1>85),4,IF(AND(A1<=200,A1>110),2,"TOO BIG")))))
The 2nd formula attempts to use a SUMPRODUCT function:
=INDEX($C$2:$C$6,SUMPRODUCT(--(A1<=$E$2:$E$6),-- (A1>$D2:$D$6),ROW($2:$6)))
Rather than have to continue to adjust the numeric values manually, I set them as absolutes, which is why this formula is slightly different. The E column is the Max value set, and the D is the Min value set.
Any help would be appreciated!
Use this:
=MATCH(A1,{0,35,60,85,110})
Another way is to use VLOOKUP and you just need to set the min number:
=VLOOKUP(D2,$A$2:$B$6,2,1)
The key is the 4th parameter needs to set to 1 which means TRUE. It will find the closest value and return the zone for you.
But noticed that you have overlaps like 35 or 60 etc. that you will need to adjust your value column.

Excel 2010 Sum of Values based on their month value and the current month

I've been looking all over for help with this, but not quite found what I'm looking for.
What I'm trying to do is add up the values of CREDIT (B2:B13) up to the current month and put that value in D2.
A B C D
1 DATE CREDIT TOTAL AS OF TODAY
2 15/01/2015 1000 4000
3 15/02/2015 1000
4 15/03/2015 1000
5 15/04/2015 1000
6 15/05/2015 1000
7 15/06/2015 1000
8 15/07/2015 1000
9 15/08/2015 1000
10 15/09/2015 1000
11 15/10/2015 1000
12 15/11/2015 1000
13 15/12/2015 1000
For example: Lets say the current date is 30th April 2015. Sum all the values in B2:B13 up to today's date based on their date value from the Date column (A2:A13). So D2 should = 4000.
I'm quite new to Excel so please forgive me if this is a stupid question.
Thanks very much in advance for any help.
SUMIF should do the trick (documentation here)
So D2's formula would be:
=SUMIF($A2:$A13,"<"&Today(),$B$2:$B$13)
The first argument is the range you want to test. The second argument is the condition you want to test for. The last argument is the range that you want to add up if the test passes.

How to calculate workdays and compensation for given period based on Employee's monthly salary?

I have only three editable fields:
salary = 15,000
start date = 18 Jul 2014
end date = 12 Oct 2014
With these fields, I need to calculate the total salary I need to pay. Payment is on a monthly basis:
(JULY = 15,000 / 31 * 14) +
(AUG = 15,000 / 31 * 31) +
(SEPT = 15,000 / 30 * 30) +
(OCT = 15,000 / 30 * 12).
I can get total days based on both dates (ie 87 days, =DAYS($enddate,$startdate)+1) ) but I need to split the days according to the months.
What formula do I need automatically to get the amount, because each person will have different salary and different dates?
You can use Excel VBA custom Function to solve your problem:
1). First, you should populate Excel Worksheet with data structure reflecting Employees Name, Monthly Salary, StartDate and EndDate, like in the following sample:
Employee M.Salary Start Date EndDate
John $15,000.00 7/18/2014 10/12/2014
Ann $20,000.00 7/19/2014 10/13/2014
Peter $16,000.00 7/20/2014 10/14/2014
Jeff $25,000.00 7/21/2014 10/15/2014
2). The DAYS in date range can be simply found by subtraction (EndDate-StartDate), because the underlying data type in integer
3). For general solution to the problem (Calculate the compensation for any arbitrary period and monthly salary) you will need to create custom VBA formula and use it in a separate column for each Employee. Refer to this article for explanation: Create a custom worksheet function in Excel VBA
4). Pertinent to your particular case with fixed date rage, the simplified solution based on the Excel Worksheet formulas (no VBA) is described below:
Employee MoSalary Start End Days FullMo FirstMo LastMo Total
John $15,000.00 7/18/2014 10/12/2014 87 30000.00 $6,774.19 $6,000.00 $42,774.19
Ann $20,000.00 7/18/2014 10/12/2014 87 40000.00 $9,032.26 $8,000.00 $57,032.26
Peter $16,000.00 7/18/2014 10/12/2014 87 32000.00 $7,225.81 $6,400.00 $45,625.81
Jeff $25,000.00 7/18/2014 10/12/2014 87 50000.00 $11,290.32 $10,000.00 $71,290.32
4a). In column E starting with row 2 add formula for DAYS : =(D2-C2)+1 and extend it for entire range
4b). In column F starting with row 2 add formula for whole months : =2*B2 and extend it for entire range
4c). In column G starting with row 2 add formula for the first month : =14*B2/31 and extend it for entire range
4d). In column H starting with row 2 add formula for last month : =12*B2/30 and extend it for entire range
4e). In column I starting with row 2 add formula for total compensation : =SUM(F2:H2) and extend it for entire range
Hope this will help. Best regards,
I have split this out because I am not entirely sure what you require and you may be able to assemble the pieces in a way that better suits you:
Assuming your data is in A1:A3, put 1/7/14 in C1, 1/8/14 in D1, 1/9/14 in E1 and 1/10/14 in F1.
To count the number of applicable days by month, in C2 enter:
=IF(MONTH($A2)=MONTH(C1),EOMONTH(C1,0)-$A2+1,IF(MONTH($A3)=MONTH(C1),DAY($A3),EOMONTH(C1,0)-EOMONTH(C1,-1)))
To compute the salary for the month by computing the daily rate for the applicable month and multiplying that by the number of days from above, in C3 enter:
=$A1*C2/(DAYS(EOMONTH(C1,0),C1)+1)
Format C2:C3 to suit and copy across to F2:F3.

Resources