Dynamically fetch values which uses complex formula from another sheet - excel

I'm using Excel 2019 (as I don't have office 365 subscription) and I've attached excel sheet at https://ufile.io/5xlkh1v3 which contains Data and Graph sheets. Data sheet contains stock tickers, quantity, date acquired, etc and Graph sheet contains array formula in column A which finds unique stocks in particular hard coded account (say eTrade from Data sheet). Similarly, column B contains formula to calculate cost for those tickers from Data sheet. Everything is working as expected in the sheet except that when I insert row in the middle of data sheet, the populated values from column A in sheet Graph disappears as the hardcoded cell reference changes.
Can someone help in making this complex array formula in column A from sheet Graph dynamically change so that its populated values will retain?
Thanks!

It would be better to post the formulas you used and ask why they cause trouble.
The following formula in Graph!A2 causes the error:
=IFERROR(INDEX(Data!A:A,SMALL(IF((Data!$I$2:$I$20="TD Ameritrade")*(Data!$J$2:$J$20="Stock")*(Data!$D$2:$D$20="")*MATCH(Data!$A$2:$A$20&Data!$I$2:$I$20&Data!$J$2:$J$20,Data!$A$2:$A$20&Data!$I$2:$I$20&Data!$J$2:$J$20,0)=ROW($1:$19),ROW($2:$20)),ROW(A1))),"")
If you insert a row somewhere in Data!$2:$20 your formula will dynamically widen that range, but this part of the formula: ROW($1:$19),ROW($2:$20) will not expand, since it's not referring to Sheet Data! if you include that it'll expand as well:
=IFERROR(INDEX(Data!A:A,SMALL(IF((Data!$I$2:$I$20="TD Ameritrade")*(Data!$J$2:$J$20="Stock")*(Data!$D$2:$D$20="")*MATCH(Data!$A$2:$A$20&Data!$I$2:$I$20&Data!$J$2:$J$20,Data!$A$2:$A$20&Data!$I$2:$I$20&Data!$J$2:$J$20,0)=ROW(Data!$1:$19),ROW(Data!$2:$20)),ROW(A1))),"")

Related

Data in column instead of rows

I am getting data from SQL Server into an Excel sheet. Its a customer table containing 20 records. The columns are Customer Code, Customer Name and Customer Short Name.
What I need is instead of data coming in rows (from row 2 to row 21)... it should come in columns.. i.e. 1st three rows of column A contains respective headers (code, name and short name) and column B first row contains value of code, second row value of name and third row value of short name... same continue to column C, D, E..... till all 20 records..
Is it possible in excel?
In Excel, you can easily transpose the array with your data. Consider the following sample data in the range A1:C4:
You could now select the entire range and copy it via CTRL+C -> Paste -> Transpose (T). A second possibility would be to enter the following formula in, e.g., cell E1: =TRANSPOSE(A1:C4). This is a dynamic array formula in the current version (Microsoft 365). If you have an older version, you have to enter the formula as a legacy array formula by confirming the formula with Ctrl+Shift+Enter.
The result is as follows:
Edit: Dynamic setting of range
Theoretically, assuming that the data structure remains the same in terms of the number of columns and rows, the formulaic approach will update the transposed array accordingly as the original data is updated. In the specification above, the range A1:C4 is hard coded. While it is very likely that the number of columns will remain the same (could also be dynamically adjusted), in practice additional rows could be added/deleted from the data. In this case, you can specify the number of rows dynamically, which solves this problem:
=TRANSPOSE(INDEX(A:C,1,1):INDEX(A:C,COUNTA(A:A),3))

How to reference Data from PowerQ that can change row

Good Afternoon.
I have a workbook that basically uses power query to take data from the CoinmarketCap Api and displays this to a sheet called "CMC".
I have a second sheet that references data in the CMC sheet. (Seen Below)
Table referencing CMC sheet
For example cell D4 references =CMC!M2+0
This is referencing the Bitcoin row which is row 2 in the "CMC" sheet. If, for example Bitcoin moved to row 3 on the "CMC" sheet then my table would be messed up and replaced with values from the new coin moved to row 2.
Is there anyway to Dynamically reference the data from the "CMC" sheet so that if a coin moves to a different row my table on sheet two can still update accordingly without me having to manually change the row?
CMC Sheet
Load the powerquery result as a pivot table report not a table
Then pull desired data from pivot table with GETPIVOTDATA formula
To enter formula, type = then click on desired cell in pivot. Example output:
=GETPIVOTDATA("Sum of Column1.price_usd",pivot_tab!$A$3,"Column1.symbol","XRP")
Alternately, leave it in the table, and use vlookup or index/match on the symbol :
=vlookup("XRP",table_tab!$a:$f,3,false)
similar to
=index(table_tab!c:c,match("XRP",table_tab!a:a,0))

How can I use a drop down list to change the reference in a formula in Excel

I have a workbook that has many sheets. Most of the sheets contain raw data. One sheet referred to as "Quick Stats" contains a bunch of various tables that take the raw data and give it meaning, such as: how many tests were taken in January; which teacher gave out the most tests; etc.). I'd really like to be able to display the stats for any given period without having to create additional sheets or tables. I'd like to select a period and have all the formulas on my stats sheet display values from the sheet that contains the data for that period.
Is there a way to have a cell (maybe a cell with a drop down list?) whose content becomes the reference point in the formulas?
For instance my sheets are named AY 13-14 (aka. academic year 2013-2014).
So if I have a formula like below
=SUM('AY 13-14'!C:C)
how can I make the sheet name of 'AY 13-14'! be the result of the value of a cell and have the formula reference the correct sheet?
Is this even possible?
Your formula will have to use INDIRECT reference based on the value of the cell with the drop down list.
For example: if you have your drop down list in the cell QuickStats!A1, then your formula will be
=SUM(INDIRECT(QuickStats!A1 & "!C:C"))
(Your drop down list would have to contain names of data sheets, e.g. AY 13-14 etc)

Excel Data Validation List using formula with filtering

I have following workbook:
Worksheet Accounts:
Worksheet Posts:
I would like to know if it is possible to define Data Validation of type List to entire column B in sheet Posts using formula, so that Data Validation popup shows only Account Ids from Accounts sheet which Website column matches Website column of a selected row in Posts sheet and which have value Active in Status column?
In SQL-ish or LINQ-ish words:
SELECT Id FROM Accounts WHERE Website =
#SelectedPostRow.Website AND Status = Active
Marks on the second image shows which values should be shown in a drop-down.
Yes you can do this, but it requires some supporting setup.
First for each of your website options, you need to create a named range for the options that would be in the drop down you are seeking to create.
To do this, just highlight the list of cells and right click, the choose Name a Range
Then you need to create a lookup list for your website names to the named range possiblities
Then in your data validation source use a forumla like this:
=indirect(vlookup(a1,$i$8:$j$13,2,false))
then whala, the dropdown list changes based upon the website value.
Now if you are also needing to automate the named range bits, you could change them to encompass entire columns and then use a pivot table to pull in the data. Would just need
an independant pivot for each website option.
Each time you pulled in fresh data you would need to refresh the pivots, but it would function.
This problem need a bit of a preparation.
In the same sheet, or in another, copy your data (or add the relevant cells)
In column A you have a number that could be ranked.
I obtained it with (cell A2):
=IF(C2=$J$2,1,0)*IF(E2="Active",1,0)*ROW()
In column B rank the number and exclude the unwanted rows (B2):
=IF(A2=0,0,RANK(A2,A:A))
Then you can VLOOKUP in column H, using a enum in column G (manually entered). The formula for H1:
=IFERROR(VLOOKUP(G2,$B$2:$D$9,3,FALSE),"")
Now you could set your validation based on column H
PS: there could be small errors in the formulas as I have translated them from italian and I cannot test in english.

Transform badly formatted excel data into a form for pivot tables

How can I transform data in excel in this form (see image here: http://imgur.com/PgX5r) into something suitable for using in a pivot chart. I need three columns eventually, Date, Country and Score. The amount of data points for each country is not constant.
The easiest way i found without using VBA is to use an array formula :
Add another column on the left of your values (let say Col A)
Set this formula on cell A1: {=INDEX(B:B,MAX(IF(ISEMPTY($C$1:C1),ROW($C$1:C1),ROW($C$1))))}
Validate with CtrlShiftEnter
Drag the formula till the end of your values
Your data are almost suitable for a Pivot Chart. What you can do next is to delete unneeded rows (with country names and headers) or use another formula on another sheet to "duplicate" the data except when unwanted rows (you can then filter the blank data in the pivot chart).

Resources