Excel: how to find the intersection (equilibrium point) between supply and demand? - excel

I have a column indicating the demand over time, a column indicating the supply cumulative volume available (always the same regardless of the time) and the price corresponding to each supply volume.
It looks like this:
demand supply price
30 5 3
12 10 7
13 15 11
23 20 13
3 25 15
22 30 21
. . .
. . .
. . .
I need in a new column, for each demand volume, the clearing price of the corresponding supply volume capable to satisfy the demand (for example in the 3rd row, the cleared price=15 is the price associated to a supply=25 which is the minimum greater volume capable to cover the demand=23). This would result as:
demand supply price cleared price
18 5 3 13
12 10 7 11
13 15 11 11
23 20 13 15
3 25 15 3
20 30 21 13
. . . .
. . . .
. . . .
I am trying with functions as: LOOKUP, INDEX, MATCH...for instance tryiong to find the smallest positive difference between supply and demand, but at the moment I'm struggling in finding a solution. Anyone has ideas? Thank you in advance

if demand in column A, price in column C and cleared price (to find out) in column D you could use :
=INDEX($C$2:$C$128, IF(ISERROR(MATCH(A2,$B$2:$B$128,1)),1, IF(INDEX($B$2:$B$128,MATCH(A2,$B$2:$B$128,1))=A2,MATCH(A2,$B$2:$B$128,1),MATCH(A2,$B$2:$B$128,1)+1)))

I think I have managed now to do something close to what I want doing:
=INDEX($F$2:$F$128;IFNA(MATCH(D2;$G$2:$G$128;1)+1;1))
MATCH is used to find out which row of the supply is greater than the demand (I add 1 because it didn't work with "greater than", so I use "smaller than" and I select the next row)
IFNA corrects to 1 those values that because of the function "smaller than" were N/A, as the demand was smaller than any possible supply.
INDEX associates the price to the MATCH result.
I still have to go through the list, but it seems to be all right.

Related

count and sum function not properly working

I am working in excel and for some reason my sum or count function is not working properly. Or, perhaps I am not using the correct function or in the right way.
A B C D E F G H
February Max March Max
1 28
2
3
4
5
7
11
15
17
19
22
23
25
IF(SUM(A:A>0),28,"")
IF(SUM(E:E>0),31,"")
I have the above columns, I want the Max columns to show a specific number only if there is data in their respective month column. February has data, so it shows 28. March does not have any data so it shows no max. I need to look at the entire column or at least a large area (row 2 to row 2000).
The issue I am having is that if I do not have a value in the first row, but do have values in later rows, the sum or count function will to recognize that and will return zero.
A B
February Max
3
4
5
7
11
15
17
19
22
23
25
IF(SUM(A:A>0),28,"")
I have tried both sum and count functions, neither are giving me the results I want. I have also tried making >= 1. I found from StackExchange that someone was having a similar problem and a solution was to change the cell format to a number. That did not work either. Any suggestions?
Per my comment, you could use COUNTA() which checks if a cell is blank.
While it doesn't answer the technical reason SUM/COUNT isn't working, it should work for your intended purposes.
=IF(COUNTA(A:A)>0,28,"")

Excel Formula needs adjusting

Please can someone help 'fine tune' this If formula that doesn't quite do what I need:
=IF(AV4=0,AP4,IF(OR(AV4>=70,AV4<=30),AP4-IF(AP4>16,4,IF(AP4<16,2,0)),AP4))
the changes I need are:
if the figure in AV is equal to or less than 30 it is deducting 4 (if AP is over 16) or 2 (if AP is under 16) but it should be adding (not deducting) 4 or 2
Also if AP is = or < 16 up or down by 2 (at present it doesn't do anything if AP is 16
The full brief is as follows:
I have present handicaps in column AP - based on whether their present handicap is 16 and over or 16 and below - I need the following to happen based n results in column AU:
if a number in column AV is higher than 70
Present handicap over 16 (column AP) - decrease by 4
Present handicap under 16 (column AP) - decrease by 2
if a number in column AV is less than 30
Present handicap over 16 (column AP)- increase by 4
Present handicap under 16 (column AP) - increase by 2
If AP is = or < 16 up or down by 2 (if AV over 70 or less than 30)
If AV = 0 - it just copies the value of AP
All rows with a result between 31 an 69 between nothing happens and the handicap in column AP doesn't change
This looks to be giving intended results. Check against your own data.
=IF(AV4>69,IF(AP4>16,AP4-4,AP4-2),IF(AV4<31,IF(AP4>16,AP4+4,AP4+2),AP4))

Excel Comparing Multiple Columns

I have a spread sheet that has computers in the furthest left column with their specs in columns B - L. There are a lot of extraneous computers in this list I don't need to work on, so I wrote a little Python script to pull out the bad values from the computer list (what was in column A). I then inserted a column to the left of column A (so what was in A is now in B and the good values are in A). I basically need to keep column A as it is, make column B match it and also remove the corresponding specs of the computers I don't need to worry about, but keep everything sorted so I know what specs go with what computer I need to work. Is there any way to do this in Excel?
thanks
Vlookup should do the trick
Assuming the current source data looks like this:
A A 1 2 3 5 6
D B 7 8 9 10 11
F C 12 13 14 15 16
D 17 18 19 20 21
E 22 23 24 25 26
F 27 28 29 30 31
G 32 33 34 35 36
and desired output is this
A 1 2 3 5 6
D 17 18 19 20 21
F 27 28 29 30 31
On a new sheet to keep it clean
Assuming SHeet1 has your current data
in Sheet2 column a Sheet4!A1
in Sheet2 column B VLOOKUP(Sheet4!B1,Sheet4!$B$1:$G$7,2,0)
VLOOKUP(Sheet4!B1,Sheet4!$B$1:$G$7,3,0) for column C and etc
dirty and tedious, but should work.
I think you should try adding data into columnA (new) based on whether the (new) columnB values feature in the good list (elsewhere), say with MATCH. If they do not #N/A should be returned and that might be used to filter on and delete what is visible.
If your 'good' list is in Sheet2 column C you might try:
=MATCH(B1,Sheet2!C:C,0)
copied down to suit.

Time Lookback Calculation

I have two columns:
Column A: Time (seconds from midnight)
Column B: Value (arbitrary value I've created)
How would I find the average value (column B) at any instance in time(row) looking back over the previous x seconds (column A)?
Lets assume A1 = Seconds after midnight
Seconds after midnight Value
0 27
2 29
6 2
16 29
20 19
24 4
34 2
40 1
44 4
54 12
64 12
71 3
81 30
91 21
92 1
93 27
97 12
104 30
112 25
Note that time deltas are variable so I can't just look at the last x rows.
A specific question would be:
In a new column (column C) return the average Value of the last 10 seconds of data.
I have no idea how to do this. Can anyone help? It'd be greatly appreciated.
EDIT:
The output in the first 4 rows of column C would be:
Seconds after midnight Value Result
0 27 No values prior to this one
2 29 27 Average(B2)
6 2 28 Average(B2:B3)
16 29 2 Average(B4)
For each row, I'm taking the current time (16 in the last case)...going back x seconds (10 seconds in this case) and then averaging the values from all the cells in that time range (not including the current value).
My main issue is the time calculation. I don't know how to calculate it as I roll forward in time and I continue to get more instances as we move forward. If we go 10 seconds without any new data point then there would be no output since. If we got one instance in the previous 10 seconds then the output would be that value. If we got 100 instances in the previous 10 seconds, I need to return the average of that 100 instances.
Again, I'd appreciate any help, hints, links. This is driving me crazy.
Try the following formula in cell C3:
=IFERROR(SUMIFS(B:B,A:A,"<"&A3,A:A,">="&A3-10)/COUNTIFS(A:A,"<"&A3,A:A,">="&A3-10),0)
SUMIFS will get the sum of all values for which the seconds are:
less than A3 (i.e. less than 2 in this case)
more or equal to A3-10 (i.e. above -8 in this case)
And this sum is divided by the number of lines found with the same criteria.
If now there is an error (more specifically when the COUNTIFS returns 0, you would get #DIV/0!) you simply get 0 instead of the error.

Rolling Time LookBack Calculation

I'm sorry if this has been answered. I've been searching around for awhile now.
I have a times series dataset that I need to perform calculations on based on the previous x time (last hour,day, etc).
My issues is that I don't know how to run these calculations since the time deltas are not standardized.
Example:
Column A - Time (in seconds lets say)
Column B - Value
Time Value Result(5)
01 3 0
02 5 3
04 4 8
07 8 9
09 6 12
13 4 6
14 4 10
15 1 8
22 9 0
33 7 0
How could I return the Result(5) column by summing the last 5 seconds from that one instance (row) (not including it)?
Thank you.
EDIT:
To clear up what I'm trying to do:
1) Find the previous 5 secs of data using column A and return that range of rows
2) Using that range of rows for the 5 previous secs, sum column B
3) Output in Column C (formula)
The following formula should do what you need (paste into C2 and drag down):
=SUMIFS($B$2:$B$11,$A$2:$A$11,">="&A2-5,$A$2:$A$11,"<"&A2)
Where YourTime is the time in the row you wish to look back and sum over.
I've tested and it works for the data you provided - expand the ranges as appropriate.

Resources