Extract a value from the chart, filtered by criteria in excel - excel

I've got two sheets like this in excel :
Price chart :
**Post AB** **Post Tenn** **Post DN**
Price 10.1-10.20 Price 10.1-10.20 Price 10.1-20.1
CityOrigin Destination 20 kg 40 kg 20 kg 40 kg 20 kg 40 kg
New York Madrid 45 40 40 50 45 40
Los Angeles Madrid 65 70 70 70 56 60
Oregon Paris 89 100 110 105 74 98
Washington Paris 34 80 45 65 45 69
and Working chart:
Price Rate
Post Career CityOrigin Date 20KG 40KG
Post AB New Tork =Today() ? ?
Post Tenn Los Angles " ? ?
Post DN Oregon " ? ?
I am wondering, is it possible to use today date with Post Career and City origin to extract only rates that are actually valid for today for 20kg and 40kg packages from price chart sheet?
My ideal result should be look like this :
Price Rate
Post Career CityOrigin Date 20KG 40KG
Post AB New York 10/20 40 45
Post Tenn Los Angles 10/20 70 70
Post DN Oregon 10/20 74 98
My question is which function I should use to call the price based on date and post career from price sheet? multiple Lookup??

So here is what I have so far without knowing how other date ranges will be like in your data structure, but this should give you something to work on.
The formula I entered in cell D13 is:
=INDEX($C$4:$H$7,MATCH($B13,$A$4:$A$7,0),MATCH($A13,$C$1:$H$1,0)+IF(D$12="20 kg",0,1))
Basically I just use INDEX/MATCH to lookup the row and column numbers. Once you have other data come in to play, I can take another look if you can't find a way around it.
Please note that I have removed the * sign on row 1 so it is easier to do in the MATCH function, otherwise, you will need to use array formula to do this and that is probably not the way you want to go.

Related

Excel: How to Use AVERAGEIFS with Multiple Ranges (different columns)

Date
Group A
Group B
Group C
Group A
Sub Group
A1
B1
C1
A2
1/1/2022
35
12
54
10
1/2/2022
43
45
62
93
1/3/2022
76
65
39
48
1/4/2022
12
25
81
18
1/5/2022
89
76
20
26
1/6/2022
23
87
47
17
1/7/2022
56
59
21
53
1/8/2022
29
51
9
68
1/9/2022
76
8
52
35
1/10/2022
36
53
38
53
User Input
Start Dt - 1/1/2022
End Dt - 1/5/2022
Group - Group B
Question
What is the daily average of a Group given the above user input?
Formula
=AVERAGEIFS(INDEX($B$2:$E$11,,MATCH($I$3,$B$1:$E$1,0)), $A$2:$A$11, ">="&$G$3, $A$2:$A$11, "<="&$H$3)
Answer
44.6
User will select a start date, end date and Group.
I want to compute the daily average of that.
The issue arises when there are multiple columns with same group as Averageif takes the first column only.
Issue - How can I find the daily average of Group A for the given dates, given that Group A are in two columns (they can't be combined as there are multiple sub groups)
If you are on Microsoft-365 then can try-
=AVERAGE(FILTER(FILTER(B3:E12,B1:E1=I2),(A3:A12>=H1)*(A3:A12<=H2)))
If you have an older version you could use:
=AVERAGE(
INDEX(A1:E12,
AGGREGATE(15,6,ROW(A3:A12)/(A3:A12>=G3)/(A3:A12<=H3),
ROW(A1:INDEX(A:A,SUMPRODUCT((A3:A12>=G3)*(A3:A12<=H3))))),
AGGREGATE(15,6,COLUMN(B1:E1)/(B1:E1=I3),
TRANSPOSE(ROW(A1:INDEX(A:A,SUMPRODUCT(N(B1:E1=I3))))))))
Entered with ctrl+shift+enter (I think)
In the picture below J3 shows the answer cell. K3 is used to demonstrate the array that is used for the AVERAGE function (a Office 365 spill range).
Another old school approach. User input fields in the formula are referenced using named ranges.
=SUMPRODUCT(($A$3:$A$12>=StartDt)*($A$3:$A$12<=EndDt)
*($B1:$E$1=Group)*($B$3:$E$12))/(COUNTIFS($A$3:$A$12,">="&StartDt,$A$3:$A$12,"<="&EndDt)
*(COUNTIF($B$1:$E$1,Group)))

How to calculate average price of open position of stocks Excel Table

I have a simple table with some dummy data to simulate stock trades. I know the its model is not exactly right, but it does comply with the basics and that's what I'm looking for.
The answer I'm looking for is how would I calculate the data on column 12. It's supposed to show the Average Price of the position at that date. If the position opened with the current row then the average price is the actual price of the trade, however the position can be increased or decreased with new prices and I want to know the average price up to that date (last two rows have this example).
Column 13 (What I got so far) has this definition*: =SUMPRODUCT([Delta Position];--([Date Trade]<=[#[Date Trade]]);--([Position After Trade]=[#[Position After Trade]]))
*actually the there's two more columns, Trader and Maturity Date, these two are used to filter data and are not shown to make it more readable: --([Person]=[#Person]);--([Month]=[#month])
(second row just shows the definition of the simpler columns)
Date Trade
Price
op
Qty
Total
Accumulated Before
Accumulated After
Position After Trade
Qty Delta Position
Delta Position
Value of Open Position
What I got so far
Average Price Open Position
C1
C2
C3
C4
C5 = C2 x C4
C6
C7
C8
C9
C10 = C9 * C2
C11
C12
C13 = C11 / C7
2021-12-06
328
Buy
99
32472
0
99
long
99
32472
HELP: 32472
32472
328
2021-12-13
291
Sell
99
28809
99
0
zero
0
0
HELP: 0
0
0
2022-01-31
190
Sell
120
22800
0
-120
short
-120
-22800
HELP: -22800
-22800
190
2022-02-14
165
Buy
120
19800
-120
0
zero
0
0
HELP: 0
0
0
2022-04-20
113,7
Sell
200
22740
0
-200
short
-200
-22740
HELP: -22740
-45540
113,7
2022-06-21
74,333
Buy
300
22299,9
-200
100
long
100
7433,3
HELP: 7433.3
39905,3
74,333
2022-08-16
86
Buy
50
4300
100
150
long
50
4300
HELP: 11733.3
44205,3
78,222
The average price of an open position is calculated by this fórmula
Average price fórmula
Iteratively you can obtain this fórmula:
Iterative fórmula
First row (first operation) => Average price = M3 = If(C3='Buy';B3;-B3)
Second row => Average price => Average price = M4 = ((M3F4)+(If(C4='Buy';B4C4;-B4*C4) )) / G4
Next rows you only have to iterate fórmula.
I hope this can help you.

In Excel how can a formula verify whether the column location or column element has taken the correct data from its header name?

The Input data
in sheet1
and
the output calculated in sheet2
Now the sheet1 data can be changed by the user for input, so now columns 'Units1' & 'Units2' may not be placed at the same address that are in columns 'C' and 'D' respectively, so suppose a new user will input the data in which 'Avocado' and 'Banana' are in columns C & D , then the 'Output' calculation in Sheet2 will be incorrect because we always want to use Units1 & Units2 for calculation.
How to fix this, so that every time the data is input the formula checks whether the correct columns have been taken for calculation or not?
Is there a way to use INDEX or family of LOOKUP functions or any other function for this.
Maybe by a creating a new sheet and making a table of Indexes which refer to (or point to) the column names of Data sheet
Location
Dates
Units1
Units2
Avocado
Banana
New York
05-01-18
10
12
1
2
Los Angeles
02-02-18
20
23
1
2
Chicago
08-03-18
30
34
1
2
Houston
05-04-18
40
45
1
2
Phoenix
02-05-18
50
56
1
2
Philadelphia
08-06-18
60
67
1
2
San Antonio
05-07-18
70
78
1
2
San Diego
02-08-18
80
89
1
2
Dallas
08-09-18
90
99
1
2
San Jose
05-10-18
100
112
1
2
Use INDEX/MATCH:
=INDEX(2:2,1,MATCH("Units2",$1:$1,0))/INDEX(2:2,1,MATCH("Units1",$1:$1,0))

Find out minimum value of specific columns in a row in MS Excel

My table in Excel looks something like this:
abcd 67 94 52 89 24
efgh 23 45 93 54 34
ijkl 64 83 23 45 92
mnop 34 45 10 66 53
This is a student database containing marks obtained in various subjects. I need to calculate the percentage in each row such that out of 5 subjects, the first subject is always included with other 3 subject with maximum marks.
Example: abcd 67 94 52 89 24 75.5%
Here 75.5%=(67+94+52+89)/4=302/4=75.5 where 24 being the lowest has been excluded and 67 has to be taken even if it were the least.
What I require is the least(excluding the first column, of course) of all the columns in that particular row, so that I can sum all the marks and subtract this least marks and finally use it to calculate the percentage.
Any help/suggestion would be appreciated. Thank You.
You'll need to adjust this for your columns, but if you sum the entire range, then subtract the min value after, do a count of the range then subtract one from that, you will be able to get the average.
This code is using the 4 values from column B through F and the 4 values are: 67 94 52 89 24... which results in 75.5
=(SUM(B3:F3)-MIN(C3:F3))/(COUNT(B3:F3)-1)

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)

Resources