Max (date) # - Min(Date) # to get the weight difference - Excel Formula - excel

I have different entries for the weight over different periods of time and wanted to see the weight difference from the max point in time to the min point in time based on a specific ID.
ID Date Weight Difference
12345 1/1/22 100 -10
12345 2/1/22 95 -10
12345 3/1/22 90 -10
44440 1/1/22 90 10
44440 2/1/22 95 10
44440 3/1/22 100 10
18258 2/1/22 105 -1
18258 3/1/22 104 -1
23584 3/1/22 110 0
So far, I have used the following formula: =MAX(IF(A:A=A2,U:U))-MIN(IF(A:A=A2,U:U))
A is the ID, U is the Weight
The formula is not taking the max date into account but the max weight and subtracting that from the min weight, instead of taking the weight from the max date and the weight from the min date.

Related

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.

Dynamically pass in name of column based on value from another

Say I have a dataframe like below.
eff_month eff_date latest_volume_month_1 latest_volume_month_2 latest_volume_month_3 pct
1 2022-01-13 55 60 70 .5
2 2022-02-10 40 50 60 .1
3 2022-03-02 30 50 70 .2
I am trying to create a new column that depending on the eff_month and pct will do some math for the values within the latest_volume_month_{eff_month} and pct.
The math: For the 1st month only take the sum of latest_volume_month_1 and multiple by pct to get vol.
For the 2nd month take the sum of latest_volume_month_1 and latest_volume_month_2 and then multiply by pct.
Third row take the sum of month 1,2,3 and multiply by pct for vol.
The expected output would look something like this.
eff_month eff_date latest_volume_month_1 latest_volume_month_2 latest_volume_month_3 pct vol
1 2022-01-13 55 60 70 .5 22.5
2 2022-02-10 40 50 60 .1 9.1
3 2022-03-02 30 50 70 .2 25

How do I create series in Excel using criteria from values in other cells?

I have an Excel spreadsheet populated as below:
Latitude
Longitude
Altitude
Value
10
10
1
100
10
10
5
105
10
10
20
120
10
5
1
150
10
5
5
155
10
5
20
170
15
10
1
500
15
10
5
505
15
10
20
520
15
5
1
550
15
5
5
555
15
5
20
570
Using this data, I would like to create a Chart in Excel where I have Value on the X-axis, Altitude on the Y-Axis and a series for each unique combination of Latitude and Longitude.
This should result in 4 series being plotted on the Chart with each series having 3 values (one value for each Altitude. I feel like this should be easy to do but I'm struggling to do it myself or find something using the grand-old Google.
Any help you could provide this Excel-noob would be greatly appreciated!
If you re-arrange your data like that
value
altitude
value
altitude
value
altitude
value
altitude
long-lat:
10-10
10-5
15-10
15-5
100
1
150
1
500
1
550
1
105
5
155
5
505
5
555
5
120
20
170
20
520
20
570
20
you can insert the four curves individually into a "points (x/y)" diagram:
Here is a screenshot of how the curves are defined:

Excel - Show summarised counts of average, min and max value from range of data

I have 2 sets of data, set 1 is a list of accounts and a count of items for each account from set 2. Set 2 data is a breakdown of the values for each account.
The examples below are representative of the data I'm working with, and there are 1000's of records so I'm after a formulaic way of doing this.
Set 1
Account Count
123 3
128 2
135 4
157 5
...
Set 2
Account Value
123 11
123 31
123 98
128 77
128 99
...
What I'd like to do, is show a set of data containing the average of the values for each account and the min and max value.
For example:
Output
Account Count Average Min Max
123 3 47 11 98
128 2 88 77 99
...
Ignore the first set and merely use Set 2 as a basis for a pivot table.
Then drag the column Value four times into the Value box and summarize by Count, Average, Min, and Max.

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