Excel slope calculation with offset defined names - excel

This formula isn't working for me ... can anyone hep?
The data is arranged:
Period cell values ranging from 1-10
The data within EnglandStat is complete and cell values ranging between 1000-2500.
The need for the defined names with offset were so a chart could automatically be updated using two named cells - Shift and Series.
i.e. Series defines that 10 period are displayed on the chart. Shift defines to move the offset range on by 1 data point.
I have two defined names:
Period=OFFSET(DATA!$A$13,COUNTA(Sheet1!$B:$B)+0-Shift,0,Series,1)
EnglandStat=OFFSET(DATA!$C$13,COUNTA(DATA!$C:$C)-13-Shift,0,Series,1)
I basically want to calculate the slope using:
=SLOPE(EnglandStat,Period)
I am getting a #REF error

Related

Identifying multiple peaks and trough in the data set of % utilization values ranging between 1 - 100

I have a series of data in one column of an Excel sheet.
I want to identify peaks and troughs in that dataset having % utilization values that are ranging between 1 - 100.
The nature of data is such that once a peak is achieved it will head downwards to a trough point and then again head upward for a peak and so on.
Can we identify multiple peaks and trough in the data set using an Excel formula or VBA code?
Peaks:
=LET(
data; B3:B50;
(OFFSET(data;1;0)<data) * (OFFSET(data;-1;0)<data))
Troughs:
=LET(
data; B3:B50;
(OFFSET(data;1;0)>data) * (OFFSET(data;-1;0)>data))
Data is the range of numbers except first and last one. I suppose it's something like B3:B50 in your case. So put the formula in C3 and look for 1's along the column C or select B3:B50 and apply the next formula for conditional formatting:
=AND(OFFSET(B3;1;0)>B3);OFFSET(B3;-1;0)>B3))

Excel Graph: X,Y points in alternating columns, different series per row

We receive a large CSV data file where each row contains a few columns of metadata and then an arbitrary length sequence of X,Y point values in alternating columns. Different rows may contain different numbers of points. The actual data may contain hundreds of rows, each with many X,Y values (possibly a couple of thousand points).
The format of this data file is not within our control.
As a simple sample for illustration:
Series 1,ID142,2,45,7,21,1,65.5,14,22
Series 2,ID082,11,23,6,15,3,29,13,84,9,78,42,45,15,17
The above example would represent two series: Series 1 with points (2,45), (7,21), (1,65.5), (14,22), and Series 2 with points (11,23), (6,15), (3,29), (13,84), (9,78), (42,45), (15,17).
The most useful way to analyze this data would be multiple series in a scatter plot in Excel. An engineer might be interested in seeing a scatter-plot with row 1 data as series 1 and row 58 data as series 2. That might lead to wanting to see a plot of row 8 and row 97. So, it would not be realistic to have a complicated process to reformat the data depending on the rows of interest.
Is there a way to easily build Excel scatter-plots with multiple series from data where each series is represented by a single row with the multiple X and Y values all in that row in alternating columns (as the sample above)?
You could use the offset function. You can open a new sheet and write this in the first cell A1, press control+ shift+ enter
and drag the formula across the columns
=OFFSET(Sheet1!A1,M,0,1,100)
similarly do this in A2 and drag it across
=OFFSET(Sheet1!A1,N,0,1,100)
This would return the Mth row from top in sheet 1 completely into first row, and Nth row into the second row. You can give reference to M and N values in different cells to make it dynamic.

Excel - Is this possible? How to use multiple lookups with index and ranges

I have (2) charts. Listing a range of numbers titles Quantity and Frequency.
I will have (2) user inputted fields in other sheets, but for now I'm just using the placeholder for this example.
So user will input a number for (QTY), and a number for (Frequency) and I need to return the value in the frequency chart.
I've used the index function before, but referencing a second value with a second chart is confusing me.
So essentially I'm trying to figure out how to do: If cell value (QTY) falls in range of chart 1 (Quantity) return the value of the (Price) chart based off frequency.
Use this:
=INDEX(C:N,MATCH(D15,A:A),MATCH(E15,C2:N2,0))

excel fix value for chart

i have some data in excel 2007 and draw a line chart with them, so i have two series: one for data and a series for average to compare data with average. now i want to add a fix value for series 2(average) to draw average line in chart.
series 2(average) value ={Sheet3!$I$18,Sheet3!$I$18,Sheet3!$I$18}
the average value is in i18 cell
but it has error about "the formula you typed contains an Error"
any body to help me to draw average line?
my data are in d24:d26 cells
and average is in i18
if i use const number it's working like below:
series 2(average) value ={5003,5003,5003}
but i want read the series value from cells, which on change the average number(i18 cell) the charge series(average line) change too.
In cell G24 enter
=$I$18
Copy to cells G25 and G26.
Now select cells G24 to G26 and copy. Select the chart and use Paste Special. Accept the defaults. The chart now has the average line.
By definition, a line needs at least two data points, beginning and end. You could leave cell G25 empty, but then you must tell Excel to connect the line between empty cells. That setting is in the Select Data dialog behind the button "Hidden and empty cells". With that approach you can avoid duplicating the average value for each data point.
Here is a screenshot with such a setup.
Edit: It can be done with just one cell but it's a lot more preparation.
Add the single cell to the chart as a new series.
Change that series to XY Scatter
Edit the series values, set X to 1, set Y to the cell value
add horizontal error bars to the average series, with settings being Plus, No Cap, Fixed value (count the number of data points in the line and enter that as the fixed value)
format the error bar line as desired and format the data marker to be invisible. Here is how this can look:

Excel: Formulas for converting data among column / row / matrix

Are there formulas to convert data in a column to a matrix or to a row?
And to convert from/to other combinations?
What about an even more complex case: reshape a matrix of width W to width N*W?
There are a few similar or related questions.
I have answered some of them, marked with *.
I keep updating this list, as new similar (or equal) questions are added:
Formatting Data: Columns to Rows *
Move content from 1 column to 3 columns *
how to split one column into two columns base on conditions in EXCEL *
writing a macro to transpose 3 columns into 1 row
Excel VBA transpose with characters
Mathematical transpose in excel
How do transform a "matrix"-table to one line for each entry in excel
Convert columns with multiple rows of data to rows with multiple columns in Excel.
How to use VBA to reshape data in excel *
Sorting three columns into six, sorted horizontally by surname using excel *
divide data in one column into more column in excel
Move data from multiple columns into single row *
Some of the answers appear to be "upgradeable" to something more encompassing.
Is that possible?
Sample formats to convert from/to are:
Column
1
2
3
4
5
6
7
...
Row
1 2 3 4 5 6 7 ...
Matrix (with a span of 4 columns here)
1 2 3 4
5 6 7 8
...
The idea is to give here something that can likely be used with minor adaptations to the questions listed above, which may also serve as a reference for future related questions.
The essential functions to be used are INDEX or OFFSET. The pros and cons of each one will be given after explicit examples, with reference to the figure. It shows several ranges with their defined names (in italics in the following).
All defined names can be replaced by direct absolute references to the corresponding cells.
1. Column to matrix
The span (in C1) gives the number of columns. Then matrix_data_top_left (D1 here) contains
=INDEX(col_data,(ROW()-ROW(matrix_data_top_left))*span+(COLUMN()-COLUMN(matrix_data_top_left)+1),1)
which is then copied into the rest of matrix_data.
Note that copying also into D5 gives an error, since the resulting formula refers to a cell outside col_data (A1:A16).
The same result is obtained in matrix_data2_top_left (I1) with
=OFFSET(col_data_top,(ROW()-ROW(matrix_data2_top_left))*span+(COLUMN()-COLUMN(matrix_data2_top_left)),0)
and copying similarly into matrix_data2.
Note that copying also into I5 returns 0, not an error.
OFFSET has the advantage of requiring only one cell to be used as a base reference (col_data_top), so extending the source data range with further data does not need redefining the source data range in the formula, one has only to copy-paste into an extended target range.
On the other hand, extending the source data range using INDEX requires first updating it in the formula (changing the range if used explicitly), and then copy-paste into an extended target range. Using a defined name is more versatile for this purpose, as redefining col_data suffices here (and it can be done after extending the target range).
Due to this same property, INDEX provides a kind of automatic bounds checking on the source range, which OFFSET does not.
2. Matrix to column
col_data2_top contains
=INDEX(matrix_data2,INT((ROW()-ROW(col_data2_top))/span)+1,MOD(ROW()-ROW(col_data2_top),span)+1)
and col_data3_top
=OFFSET(matrix_data2_top_left,INT((ROW()-ROW(col_data3_top))/span),MOD(ROW()-ROW(col_data3_top),span))
Both formulas are copied downwards.
The same differences between INDEX and OFFSET exist.
3. Matrix to row
Since OFFSET does not give errors, the remaining formulas will use it. Adapting for INDEX along the lines shown above is easy.
row_data_left contains
=OFFSET(matrix_data_top_left,INT((COLUMN()-COLUMN(row_data_left))/span),MOD(COLUMN()-COLUMN(row_data_left),span))
then copied to the right.
4. Column to row
row_data2_left contains
=OFFSET(col_data_top,COLUMN()-COLUMN(row_data2_left),0)
again copied to the right.
PS: The formula =TRANSPOSE(... works for this case, and it should be entered as an array formula (with ctrl+shift+enter). Nevertheles, it might be desirable to avoid array formulas.
5/6. Row to column/matrix
It is very easy to obtain along these lines.
E.g., col_data_top contains
=OFFSET(row_data_left,0,ROW()-ROW(col_data_top))
and copy down.
7. Matrix transpose
To get in matrix_data3 (not shown in the fig.) the transpose of matrix_data2, one only needs to use matrix_data3_top_left, with the formula
=OFFSET(matrix_data2_top_left,COLUMN()-COLUMN(matrix_data3_top_left),ROW()-ROW(matrix_data3_top_left))
and copied to a suitable target range.
8. Matrix reshape
We want to reshape a matrix into a wider one:
matrix_data4, with N4 rows and M4 columns (width4), into
matrix_data5, with N5=N4/R rows and M5=M4xR columns (width5), with R (rep5) the number of repeats
(matrices not shown in the fig.) Then use
=OFFSET(matrix_data4_top_left,(ROW()-ROW(matrix_data5_top_left))*rep5+INT((COLUMN()-COLUMN(matrix_data5_top_left))/width4),MOD((COLUMN()-COLUMN(matrix_data5_top_left)),width4))
Now we want to reshape a matrix into a narrower one:
matrix_data4, with N4 rows and M4 columns (width4), into
matrix_data6, with N6=N4xS rows and M6=M4/S columns (width6), with S (split6) the number of splits
(matrices not shown in the fig.) Then use
=OFFSET(matrix_data4_top_left,INT((ROW()-ROW(matrix_data6_top_left))/split6),MOD((ROW()-ROW(matrix_data6_top_left)),split6)*width4+(COLUMN()-COLUMN(matrix_data6_top_left)))

Resources