Extracting the Projected Data in Excel - excel

When we add a trendline to a chart, Excel provides an option to display the trendline equation in the chart.
We can then use these formulas to calculate predicted y values for give values of x
The formulea are nicely listed by SpreadSheetPage.Com
I wanted to implement the same in the excel sheet for a dataset like given below:
Year Value
1990 400
1991 494
1992 449
1993 554
1994 600
1995 499
1996
1997
1998
1999
2000
As you can see, I wanted to project the values for the years 1996 to 2000 using 2nd Order Polynomial.
Using the equations provided by SpreadSheetPage.Com
2nd Order Polynomial Trendline
Equation: y = (c2 * x^2) + (c1 * x ^1) + b
c2: =INDEX(LINEST(y,x^{1,2}),1)
C1: =INDEX(LINEST(y,x^{1,2}),1,2)
b = =INDEX(LINEST(y,x^{1,2}),1,3)
I calculated C2 and the stored the value in a cell whith cell address say C2.
Similarly, I calculated C1 and stored the value in a cell with cell address say C1. I also calculated b and stored the value in a cell with cell address say C3.
Then, in the cell besides the year 1996 (whoes value I want to project), I entered the formulea = (c2 * x^2) + (c1 * x ^1) + C3 and Ctr+Shift+Entered for the array formulea while selected the value cells from 1996-2000.
The results were not as expected. I am sure I am not using these equations in their proper way. Any help in this regard will be highly appreciated.
Please not I have made named arrays x and y for known x's and known y's respectively.

Given the limitation that you don't provide your actual or expected results:
Assume your known table is A1:B7, and your ranges are named as you mentioned:
B8: = (C$2 * A8^2) + (C$1 * A8 ^1) + C$3
and fill down to B12
Using a different function, you could use:
B8: =TREND(y,x^{1,2},A8:A12^{1,2})
Then select B8:B12 and enter as an array with ctrl+shift+enter. Note that this function may be inaccurate in versions of Excel prior to 2007.
EDIT
Note that the original formula can be entered as an array if we replace A8 with A8:A12; and the TREND function can be entered normally, and filled down, if new_x is entered as a single cell, instead of a range.

Related

If function and Xlookup

I am currently trying to run an excel function that runs the logic that if the cell that has date X is greater than date 2023-01-01 then run an XLookup function. If it is not then do not run it.
Here's what I tried below:
=IF(table2!N5>DATE(2023,1,1),XLOOKUP(A2,'Table2'!A:A,'Table2'!B:B),"FALSE")
N5 has the date 2022-12-01. The rest is just a standard xlookup function that would run if cell N5 is greater than the date 2023-01-01.
Data for the Xlookup below:
Table 1 : This table provides the lookup value A1.
A B C
1 Position Classification Full Name
2 111111 IT 04 John Smith
Table 2 : This table provides the lookup array being A:A and the return array being B:B
A B C D
1 Employment Position CC Valid From Valid To
2 111111 8888888 2022-10-01 2023-03-31
As posted in comments, I will suggest you use a cell reference, so it becomes more dynamic to use, instead of hard coding within a formula,
• instead of this
=IF(N5>0+"2023-01-01",XLOOKUP(E3,H:H,J:J),"FALSE"))
• Use a cell reference, let's say cell A1 = 2023-01-01
=IF(N5>A1,XLOOKUP(E3,H:H,J:J),"FALSE"))
So the above helps you in changing the cell A1 values whenever you need instead of bothering the formula each time for a change.
I would advise you to use the DATE() function, like this:
= IF(A1>DATE(2023,1,1), ...)

Formula Help SUM Based on Given Value

i have data in Column A - Days and Column B - Sales i want calculate running total based on Days Value like
Column A Column B
Day1 150
Day2 200
Day3 175
Day4 250
i want total running sum in Column E Based on Value in Column D
here i applied this formula to running sum based on cell value
=SUM($B$2:B2,INDEX($B$2:B5,MATCH($D$2,$A$2:A5,0)))
here i have getting wrong result like if i enter (Day3 in Cell D2 getting result in Cell E2 - 325) it's wrong
The syntax is just a bit off, you should add up the range from B2 to the position found by the match, in this case B4:
=SUM($B$2:INDEX($B$2:$B$5,MATCH($D$2,$A$2:$A$5,0)))
This works because Index returns a reference and can be used as one end of a range.

How to use the Polynomial Trendline Formula

So the blue line graph has values from column CM (x values are in column CF, sorry for the confusing presentation). I want to recreate the polynomial trendline that I had excel generate for it, which is what I'm trying to do in column CH, as you can see from the formula bar.
Excel gives me the formula y = -0,0006x^2 + 0,013x + 0,1878 (shown on the chart) which I then have entered into the values in column CH.
The result is unfortunately not even close (displayed as the orange line graph). Is there any person here sharp enough on maths to tell me what I'm doing wrong?
This is the formula to obtain 2nd Order Polynomial Trendline:
y = (c2 * x^2) + (c1 * x) + b
c2: =INDEX(LINEST(y,x^{1,2}),1)
c1: =INDEX(LINEST(y,x^{1,2}),1,2)
b: =INDEX(LINEST(y,x^{1,2}),1,3)
So now, just examined your formula, you have incorrect parameters (b, c1 and c2) used so the result is different.
Here are the formulas I used to obtain these three parameters:
c2: =INDEX(LINEST($CM$1234:$CM$1262,$CF$1234:$CF$1262^{1,2}),1)
c1: =INDEX(LINEST($CM$1234:$CM$1262,$CF$1234:$CF$1262^{1,2}),1,2)
b: =INDEX(LINEST($CM$1234:$CM$1262,$CF$1234:$CF$1262^{1,2}),1,3)
Then I got:
c2 (cell CG1227) = -0.05675
c1 (cell CG1228) = -0.04025
b (cell CG1229) = 0.25509
Now, from cell CH1234, this formula is used:
=($CG$1227*CF1234^2)+($CG$1228*CF1234)+$CG$1229
I have the outcome matched with the Polynomial Trendline. Try and see if this works for you.

Find the nearest set of coordinates in Excel

There are two tables, each with a coordinate pair: longitude and latitude, in decimal degrees (i.e. 37.23222, -121,3433). How do I match table A with its nearest coordinate pair in table B?
You could try filling down this formula from G1 as shown below:
=LOOKUP(1,1/FREQUENCY(0,MMULT((B$1:C$10-E1:F1)^2,{1;1})),A$1:A$10)
For a more accurate formula that takes account of the circular distances try filling down from H1:
=LOOKUP(1,1/FREQUENCY(0,SIN((RADIANS(B$1:B$10-E1))/2)^2+SIN((RADIANS(C$1:C$10-F1))/2)^2*COS(RADIANS(B$1:B$10))*COS(RADIANS(E1))),A$1:A$10)
This problem was solved back in 2006 by Tom Ogilvy here, also found here.
The sample that I created:
Original problem:
I have 20 named locations in a coordinates. Every point have x,y.
column a has the location name
column b has the x cooedinate
column c has the y coordinate
Now i have 400 coordinates in 2 columns (column e and f ) and want to
have the name of the closest location (of the 20 named in column a) in column g.
Original solution by Tom Ogilvy:
Assuming original data starts in A1, B1 and C1 with first locations in E1
and F1
If you don't want to fill your sheet with formulas, you can put this in G1
committed/entered with Ctrl+Shift+Enter rather than just enter since it is
an array formula, then drag fill it down the 400 rows.
=INDEX($A$1:$A$20,MATCH(MIN(SQRT(($B$1:$B$20-E1)^2+($C$1:$C$20-F1)^2)),SQRT(
($B$1:$B$20-E1)^2+($C$1:$C$20-F1)^2),0),1)

Averaging daily varying column in excel vb

Every day I have to analyze two cols of numbers.
Cols differ each day.
Col 1 has no.'s from 1 to 5, eg. Day 1 there are 150 x 1's and 200 x 2's, etc. Day 2, 350 x 1's and 85 x 2's etc.
Col 2 has values between 1 and 99.
I need to count how many 1's there are to obtain a 1's average, 2's ave., etc. So far I have tried to write a vb program (excel 2010) - I have written the following:
Function Phil2()
ct = 0
For X = 2 To 10
If ax = 1 Then Let b15 = b15 + bx
ct = ct + 1
Next
End Function.
But I cannot get it to display. Can anyone help me?
I want the average of the 1's in cell b15.
See the formula bar for what is in cell E1. If you don't have XL2007 or above, the formula becomes:
=IF(ISERROR(SUMIF($A$1:$B$10,D1,$B$1:$B$10)/COUNTIF($A$1:$B$10,D1)),"",SUMIF($A$1:$B$10,D1,$B$1:$B$10)/COUNTIF($A$1:$B$10,D1))
You could also make more "automated" by using Dynamic Named Ranges for your ID (1,2,3..) and data (%) sets, that change each day.
OK, It works fine - I modified your formula to:
=IFERROR(AVERAGEIFS(B$16:B$500,$A$16:$A$500,$A2,B$16:B$500,">0"),"")
and it works perfectly for values 1, and 2. So that's a great start. I placed the formula cells on top: so in a1 I typed cow no., in b1 %Milk, in c1 %weight, etc.. In a2 I typed 1, a3 2, a4 3 etc.. In b2 your formula etc.. My next challenge is to lump together all cow types 3 to 11. So next to cow type 1 we have a % for each category, same for cow type 2, etc.. But the 3rd row must have an average for all categories 3+. Raw data cow types are in a10 down, vals in b10, c10, etc.

Resources