Find a value based on one criteria and two match ranges - excel-formula

I have two data sources:
Source 1 contains product id and price date, need to find the price that corresponds with the date from Source 2 based on product id and between two date ranges because there is no exact date match. Here are the tables:
Source 1
Product ID Price Date Need price
2512330 05/07/2016 ???
2512330 06/07/2016 ???
2512330 06/13/2016 ???
2512330 07/20/2016 ???
2512330 08/27/2016 ???
2512330 09/22/2016 ???
Source 2:
Product ID Current Update Price First Update Price Second Update Price Third Update Price Fourth Update Price Fifth Update Price
2143480 5/2/2017 405.60 8/18/2016 375.60 12/23/2015 344.88 5/29/2015 319.08 10/20/2014 292.99 10/1/1996 0.00
2512330 5/2/2017 18.36 12/6/2016 16.70 6/3/2016 15.62 12/1/2015 14.22 5/14/2015 12.94 12/4/2014 11.77
3089421 1/1/2017 7.77 4/1/2016 7.20 8/24/2015 6.67 12/15/2014 6.30 3/17/2014 5.83 8/30/2013 5.31
Thank in advance for your help.
octord

Use this formula:
=INDEX(A:M,MATCH(P2,A:A,0),AGGREGATE(15,6,COLUMN(INDEX(A:M,MATCH(P2,A:A,0),0))/((INDEX(A:M,MATCH(P2,A:A,0),0)<=Q2)*(ISEVEN(COLUMN(INDEX(A:M,MATCH(P2,A:A,0),0))))),1)+1)
You may need to change the ISEVEN to ISODD depending on the column in which the dates are found.

Related

Way to find value in a date range Excell

I have Start date + time and End date + time in table 1, then i have a range of dates and values in table 2. what i want is to find the highest value from table 2 that happened in the date range from table 1.
For example in table 1:
start date 12/30/2020 08:03 ; end date 12/31/2020 17:26
in table 2 is:
12/30/2020 08:00 1145
12/30/2020 09:00 2145
12/30/2020 10:00 3912
12/30/2020 08:00 1472
and so on. so in the row of table 1 i want to see the number 3912
Suppose both of your tables are structured reference table as shown below:
You can use either of the following formula to return the desired value:
=MAX((Table2[Date]>=Table1[#[Start Date]])*(Table2[Date]<=Table1[#[End Date]])*Table2[Value])
This one is using MAXIFS as suggested by Nicholas Hunter in the comment section:
=MAXIFS(Table2[Value],Table2[Date],">="&Table1[#[Start Date]],Table2[Date],"<="&Table1[#[End Date]])
Assuming table 1 = A1-B10 and table 2 is in D1-10,
try making another column (lets say F1-10) with the following: =IF(And(D1<B1,D1>A1),D1,0)
and in whatever cell you want the highest Date, put =Large(F1-10)
Make sure that the final cell has "Date" format, otherwise it will look like a weird number. if you want to look at the intermediary steps, do the same for F1-10.

If exist in range in excel

I have a problem with excel!
I need to check a list of values and if my value is exist between start and end in my list , get a price of which one is match in list
My product list this :
Id
Data
Product_Name
Price
1
9905
Mouse
$200
2
9915
Power
$300
1
9925
Case
$400
My Price list is :
Id
Start
End
Price
1
9900
9910
$200
2
9911
9920
$300
3
9921
9930
$400
Check Data in Product list is between Start and End in Price list and if Data is between Start and End so get me a value of Price
thhank!
VLOOKUP will do this:
=VLOOKUP(B2,H:J,3)
One note, make sure the lookup table is sorted ascending on the start column.

Add Partial Text Match as Criteria to a Count Unique Formula

I've been trying to add a partial text match as a criteria to the formula below, but with no success so far:
=SUM(--(FREQUENCY(IF(Sales[ClientID]=A21;IF(Sales[Operation]="Sale*";Sale[InvoiceNumber]));Sale[InvoiceNumber])>0))
The piece IF(Sales[Operation]="Sale*"; is the one that when added, always give me 0 as the result.
Here's some data:
Sales Table
Date ClientID Operation InvoiceNumber Total
01/01/2019 18090 Sale Adv 101010101 100
01/02/2019 20897 Sale Cash 105327892 100
01/03/2019 18090 Sample 41357398 100
01/01/2019 30456 Sale Check 43167429 100
10/04/2019 779584 Sale Cash 4326719 100
01/05/2019 30456 Refused 34162781 100
01/01/2019 90909 Sale Cash 3412679821 100
Results Table
ClientID Purchase Frequency
779584 ???
Here's the solution I borrowed from Scot Craner, in case someone else falls into the same question:
=SUM(--(FREQUENCY(IF(Sales[ClientID]=A21;IF(ISNUMBER(SEARCH("Sale";Sales[Operation]));Sale[InvoiceNumber]));Sale[InvoiceNumber])>0))
Thanks everyone!

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.

How to vlookup on 2 columns and return total value of another?

I've got a table in Excel which is structure like so:
Month Date Time ID Name Currency Value
Jan 07/01/14 5 1234567 Ted GBP 500
Jan 10/01/14 12 1234567 Ted GBP 723
Feb 23/02/14 6 9877654 John GBP 300
Feb 10/02/14 10 1234567 Ted GBP 333
What I need to do is write a formula which basically returns be the total of Value where ID and Month are equal to whatever the lookup values are. For example, using the above I would say:
Find the total of Value where Month equals Jan and ID equals 1234567.
The answer in this case would be 1223.
Ive just tried
=SUMIFS(INPUT!H:H,INPUT!D:D='TRANS BY MID'!B2,INPUT!A:A='TRANS BY MID'!C1)
INPUT!H:H is my ID column
INPUT!D:D='TRANS BY MID'!B2 is the ID I want to use
INPUT!A:A is the Month column
TRANS BY MID'!C1 is Jan
To provide a working solution I simplified your question into one sheet. The data appears like this:
You can link your other sheet to the values shown in column J.
The formula is now this:
=SUMIFS(G:G,D:D,J1,A:A,J2)
The result is shown in J7:

Resources