Closest Combined Match in Excel - excel

I need to come up with a formula that gives me the closest match based on multiple criteria.
This only applies for those names with Valid = "N" (Column I), or else their own name is returned.
For example, Bob has the closest numbers combined to Susan for each day.
I rearranged all of the "valid" names in the table to the right so that Bob does not return "Bob" as the closest match (since we only want to return names that are valid anyways).
I have attached an image of the data below (with column J being my desired results)
Name
Sunday
Monday
Tuesday
Wednesday
Thursday
Friday
Saturday
Valid (Y/N)
Desired Combined Closest Match
Calculated Closest Match
Bob
100
25
750
40
750
750
750
N
Susan
Susan
Susan
100
25
500
25
1000
1000
1000
Y
Susan
Susan
Karen
75
30
500
50
Y
Karen
Karen
Michele
100
30
500
50
Y
Michele
Michele
Tom
75
30
240
30
Y
Tom
Tom
Rob
100
30
1000
30
Y
Rob
Rob
Brian
100
30
1000
50
N
Rob
Susan
Stacy
100
30
500
50
Y
Stacy
Stacy
Rachel
100
30
500
50
2000
2000
2000
Y
Rachel
Rachel
Jeff
100
30
500
50
1000
1000
1000
N
Susan
Susan
I am able to do this only using 1 column of data, but I am unsure how to combine them. I used INDEX, MATCH, MIN, and ABS functions to figure out the closest match based on one column (Sunday). Here is an example of my formula for Brian (it is supposed to return "Rob" as the result, but returns "Susan" because I only am using one day of data):
=IF(I8="Y",A8,INDEX($M$2:$M$8,MATCH(MIN(ABS($N$2:$N$8-B8)),ABS($N$2:$N$8-B8),0)))

Related

SUMIFS across multiple sheets

So I'm working on a workbook right now that is across 3 sheets, 'Data', 'RAW', 'Lookup'. On the Data tab it looks like, Sheet 1
A B C D E
Segment Ranking Amount Revenue Spend
Carbon 15 2 5000 550
Oxygen 30 3 6895 450
Minerals 45 1 4400 350
The Code I use for each column are as follows (Some of the Columns are named columns)
B =IF(NOT(ISERROR(SEARCH("OK",$A2))),SUMIFS(RAW!B:B,Output,"*"&INDEX(SegmentID,MATCH($A2,SegmentName,0))&"*"),SUMIFS(RAW!B:B,Output,"*"&INDEX(SegmentID,MATCH($A2,SegmentName,0))&"*",Output,"<>*OK*"))
C =IF(NOT(ISERROR(SEARCH("OK",$A2))),SUMIFS(RAW!C:C,Output,"*"&INDEX(SegmentID,MATCH($A2,SegmentName,0))&"*"),SUMIFS(RAW!C:C,Output,"*"&INDEX(SegmentID,MATCH($A2,SegmentName,0))&"*",SegmentName,"<>*OK*"))
D =IF(NOT(ISERROR(SEARCH("OK",$A2))),SUMIFS(RAW!D:D,Output,"*"&INDEX(SegmentID,MATCH($A2,SegmentName,0))&"*"),SUMIFS(RAW!D:D,Output,"*"&INDEX(SegmentID,MATCH($A2,SegmentName,0))&"*",Output,"<>""OK"))
E =IF(NOT(ISERROR(SEARCH("OK",$A2))),SUMIFS(Spend,Output,"*"&INDEX(SegmentID,MATCH($A2,SegmentName,0))&"*"),SUMIFS(Spend,Output,"*"&INDEX(SegmentID,MATCH($A2,SegmentName,0))&"*",Output,"<>*OK*"))
The RAW Sheet looks like (Sheet 2)
A B C D E
Output Ranking Amount Revenue Spend
Random_1234_Random 15 2 5000 550
Random_5678_Random 30 3 6895 450
Random_9102_Random 45 1 4400 350
Random_555_Random 60 4 4000 300
The Lookup Sheet Looks like (Sheet 3)
A B
Segment ID
Carbon 1234
Oxygen 5678
Minerals 9102
Carbon 555
The problem that I have right now is, it will only grab the first Carbon with ID 1234, and not grab the second Carbon with ID 555 at all resulting in:
A B C D E
Segment Ranking Amount Revenue Spend
Carbon 15 2 5000 550
The end result that I would like is for it to grab ALL Carbon with any ID and add all of them together as below into a single line. (RAW sheet, Random_1234_Random + Random_555_Random)
A B C D E
Segment Ranking Amount Revenue Spend
Carbon 75 6 9000 850
Any help would be great and if I need to provide more detail please let me know!
Thank you in advance,
Maykid

Excel How to make a formula differenciate different vehicle plates

I have little knowlage of excel and I'm trying to configure an excel table so I can get the consumption of gas for each vehicle in a company, but all the data is introduced in only one table, how can I calculate the increase of km's of each vehicle to then be able to calculate the consumption?
The problem is that I don't know how to make the formula differenciate for each different plate.
The table is the following:
**A B C D E F G**
**1** Date Plate km Gas Signed Increased km's Consum
**2** 1/1/2018 0157-AAA 123456 50 YES
**3** 5/1/2018 0157-AAA 123789 20 NO
**4** 8/2/2018 0157-AAA 123987 30 NO
**5** 1/2/2018 0582-BBB 123456 40 YES
**6** 1/3/2018 0356-CCC 123456 30 NO
Another exemple:
Data Plate km Gas Increased km Consum %
3/5/2017 1111-AAA 150 20 150 13,33333333
7/5/2017 1111-AAA 400 30 250 12
7/5/2017 2222-BBB 50 10 50 20
7/5/2017 3333-CCC 20 5 20 25
10/5/2017 2222-BBB 200 30 150 20
Each plate is a different vehicle
Gas is the amount of oil that the vehicle refills in L
The table is updated daily or every 2-3 days as it's manually filled
The problem is calculating the increased km's as they may be other plates in between in the same date.
Consum % = Gas/Increased km *100
I thought about just ordering the columns by date and by plate and apply a general formula to everything
Thanks
I think I finally "solved my problem", the formula with the one I work is based on a filter for the plates in order to get them ordered. then the formula is:
Increased km =IF(B2=B1;C2-C1;C2)

Checking thresholds and calculating the recovery time

This is what I would like to have happen:
Car ID Sample point Date Viscosity Output
123456 1 01/01/2016 400
123456 2 01/01/2016 100
123456 3 01/01/2016 100
123456 1 01/06/2016 100
123456 2 01/06/2016 80
123456 3 01/06/2016 90
123457 1 01/01/2017 600
123457 2 01/01/2017 800
123457 3 01/01/2017 900
123457 1 01/06/2017 200
123457 2 01/06/2017 100
123457 3 01/06/2017 50
Max. Viscosity Threshold 300
Normal Viscosity Level 200
I wish to check a viscosity recovery. It means I would like to first check Car ID, Sample point , Viscosity Value.
If Viscosity value is higher >300
I would like to check the next data set (same ID, Same sample point, next date) if for the same sample point viscosity came back to the normal value (<200) if not, proceed to the next date.
When Sample ID is finished, proceed to the next ID.
Later on for all data sets I wish to calculate the average recovery time.
Example:
Step 1
Car ID 123456 Sample 1 Date 01/01/2016 Viscosity 400 Above Threshold
Step 2 'Checking for the Sample 1 next sampling if viscosity went lower then Normal threshold
Row 4 Car ID 123456 Sample 1 Date 1/06/2016 Viscosity 100 Below Normal Threshold
Output(recovery time): column 5: 5 months. End
Step 3 checking other sample point. If nothing finds, continue with the next car ID.
Please find here picture with the actual spreadsheet.

Error in COUNTIFS function

I want to count how many vehicles are delayed more than 4 min on a given day according to a given departure (let's assume from 00:00 to 05:00).
This is a sample of the data:
A B C D
1 Line Day Departure Delayed (sec)
2 11 Weekday 02:30:00 120
3 11 Weekday 03:40:00 500
4 22 Weekday 01:45:00 10
5 44 Weekday 06:44:00 1000
6 55 Weekday 04:35:00 145
7 111 Saturday 14:40:00 450
8 111 Saturday 04:20:00 300
9 111 Saturday 20:20:00 220
10 111 Saturday 07:00:00 125
11 333 Sunday 09:15:00 700
I used a "TÆL.HVISER" function (Danish) or COUNT.IFS function to count the vehicles:
=TÆL.HVISER(A2:A11;"11";B2:B11;"Weekday";C2:C11;00:00:00>C2:C11>05:00:00;D2:D11;">240")
But it is not working. When I break this restriction into four restrictions, the individual restrictions are working but when I combine them it's not working.
I've laid out your data according to how I read your sample formula.
    
The EN-US formula in G4 is,
=COUNTIFS($A$2:$A$11, G$3, $B$2:$B$11, $F4, $C$2:$C$11, ">="&TIME(0, 0, 0), $C$2:$C$11, "<="&TIME(5, 0, 0), $D$2:$D$11, ">="&240)
Fill both right and down. I've use the TIME function so that a) real times could be referenced and b) it makes it easier to set to new values.
TÆL.HVISER, funktionen
Funktionen TID
It is the part
00:00:00>C2:C11>05:00:00
if you change it to two criteria like this
C2:C11;">00:00:00";C2:C11;"<05:00:00"
it will work. Here is the full formula:
=COUNTIFS(A2:A11;"11";B2:B11;"Weekday";C2:C11;">00:00:00";C2:C11;"<05:00:00";D2:D11;">240")

Return values in same row by searching different column

Given data like this:
A B C D
1 MAX. Time MIN. Time
2 140 08:00 100 01:00
3 150 15:00 50 02:00
4 130 17:00 80 03:00
5 120 22:00 90 04:00
=MAX(A2:A5) will return 150 and
=MIN(C2:C5) will return 50
How can I find the values in COL B in same row as 150 (for MAX) and in COL D in the same row as 50 (for MIN)?
If you can confirm that you have only one max(min) value (if not, formula returns first occurance), you can simply use VLOOKUP:
=VLOOKUP(Max(A2:A5),A2:B5,2,0)
for min formulaa would be the same:
=VLOOKUP(Min(C2:C5),C2:D5,2,0)
Alternatively you can use more flexible formula:
=INDEX(B2:B5,MATCH(Min(C2:C5),C2:C5,0))
above formula finds min in column C and returns corresponding value from col B

Resources