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))
Related
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))),"")
I'm trying to import all data from nth columns, starting from the 3rd row, from one worksheet ('Dataimport') to another ('Cleaned Data') in the same spreadsheet, but so far I have only managed to get a specific cell from every nth column:
=INDEX(Dataimport!$C$3:$HI$3;(ROWS($A$1:A1)*6)+1)
Right now I'm doing it manually, using =TRANSPOSE(IMPORTRANGE("1yyb1k0uAdN1XcLWBhNq4jA0eInnePRoUt9IbuXDmfEU";"Dataimport!I3:I300")) in every cell, so that the column data is imported horizontally (this is how it's supposed to look like):
The sheet with data looks like this. Here I want to retrieve data from every 7th column starting from column C:
Any idea how I do this?
Public link:
https://docs.google.com/spreadsheets/d/1hXFiSoduVjcZ6fbOcyp-BfI7m4So-01umLS0kBm-lVI/edit?usp=sharing
Proposed solution
Given your attempt =INDEX(Dataimport!$C$3:$HI$3;(ROWS($A$1:A1)*6)+1), I would suggest using the Google Sheets Formula OFFSET that allows specifying indexes as mathematical operations.
You will be able to specify the column offset with a simple mathematical operation in order to get the next needed indexes for the rows below.
Here is an example:
=TRANSPOSE(OFFSET(Dataimport!C$2:C$199;1;(ROW()-1)*6;199;1))
With this formula you can obtain the right column form the Dataimport Worksheet and then transpose it in order to fit it in a row.
Putting this formula in the Clean Data "D2" Cell will compute a column offset of 6 starting from the 3rd column ("C") considered in the OFFSET formula. Dragging down the formula will adjust the column offset index to the needed 7 columns range.
Reference
OFFSET
I think I have a solution.
I've build a spreadsheet with dummy data and then I made a formula that takes every nth column from the table.
Here is my solution:
https://docs.google.com/spreadsheets/d/1J6x4H_cNczRRo40Ri6Nwa-YnZOISpxZmG4-JZ7tA1kA/copy
First I make an ID column to both tables to let vlookup work
I use vlookup and arrayformula formula for this:
For grabbing multiple columns I use sequence formula within vlookup.
This makes an array of numbers with defined step. So if you can have every 6th column you define step as 6. Here step is defined in cell c23
=ArrayFormula(vlookup(A24:A43,A2:AB21,sequence(1,5,4,C23),false))
Of course it can work in multiple sheets or files. You just need to use importranges instead of standard references to a range.
I have a workbook what has a tab (Clarity) with a large range of historical information (columns A-IV & c15k rows).
I have created a second tab to search the Clarity information using 1 or more keywords.
Cell C2 is the keyword input cell and I want the results (using a small subset of 12 of the columns) to be displayed in a separate table.
I have created the following formula in cell C5 (using ctrl shift enter):
{=IFERROR(INDEX(Name,SMALL(IF(ISNUMBER(SEARCH($C$2,Name)),ROW(Name)-ROW(INDEX(Name,1,1))+1),ROWS(C$5:C6))),"")}
and then copied this formula down through to cell C30. I have then created VLOOKUPs in the other 11 columns based on the information in column C.
It seems to work but it creates duplicate records where there aren't in the source data.
It only searches on one column (column D in the Clarity tab, which I have named "name")
It takes about 10-20 seconds between entering the keyword and getting the results.
If I try and make it search all columns, I get no results - Is there a problem with my formula? Is there a more efficient way of doing this?
=IFERROR(INDEX(Name,SMALL(IF(ISNUMBER(SEARCH($B$2,Name)),ROW(Name)-ROW(INDEX(Name,1))+1),ROW(1:1))),"")
I updated ROWS(C$5:C6) to just reference ROW(1:1) so that the first smallest match is found first and the row will update when the formula is dragged down.
Let's say you want to evaluate against the whole row, make the name manager store the whole concatenated row as each array object.
I thought this should be a common thing but my search has not returned anything meaningful. I'd prefer an Excel solution, rather than VBA.
I have a proposal sheet with details like number (col D), date etc and a column saying if the proposal got converted (to business).
On the invoice sheet, I have a list of invoices. The requirement is to always refer the proposal number against which this invoice is being raised. For removing human error, the applicable proposal numbers should be available as a drop down. Hence the drop down should only show the proposal numbers against which the invoice can be issued (proposal got converted to business).
This means that non-continuous cells (say, D3, D4, D6, and D10 - where proposal converted is 'yes') from the proposal sheet should be the values available in drop down of data validation in the invoice sheet. How do I achieve this?
Edit:
Adding an image that is representative of the 2 sheets.
My solution involves creating a list using the INDEX MATCH or INDEX SMALL method to pull multiple results from the data that can be used for the dropdown.
I added a couple of extra columns to count the number of times an invoice has been invoiced and then a further Yes/No to make the index formula easier to follow. You'll see that my example only has 2 values to select from as the others have been fully invoiced.
The scary formula in Q1
=IFERROR(INDEX($A$2:$H$1000,SMALL(IF(($H$2:$H$1000="Yes"),ROW($A$2:$H$1000)-1),ROW(1:1)),1),"")
This is an array formula so you must use SHIFTCTRLENTER instead of just ENTER in the formula bar. {} backets will be added if you do it right.
To break it down, INDEX($A$2:$H$1000 is selecting your proposal data and some more rows below (1000). SMALL(IF(($H$2:$H$1000="Yes") is looking at my extra Yes/No column for "Yes". ROW($A$2:$H$1000)-1) is returning the row number minus 1 to account for the fact that our range starts at A2. ROW(1:1) is saying that we want first match in the list and the ),1) returns the vlue in the first column of the range $A$2:$H$1000.
Because ROW(1:1) returns the first result, you will need to autofill down in order to pull more results. As you do this the formula will copy down as 1:1, 2:2, 3:3...ect. I filled down to row 50 to allow for a decent amount of results.
You could set your validation range to Q1:Q50 but then you would have lots of empty space in your dropdown so, have a look at cell R1.
="Q1:Q" & COUNTA(Q1:Q50)-COUNTBLANK(Q1:Q50)
This formula creates a range based on the results in column Q. You can use that value in the data validation range by entering.
=INDIRECT($R$1)
Thus creating the dynamic range that you require.
You don't have to use the extra columns that I added but the formulas are;
=COUNTIF(M2:M1000,A2) to count the number invoiced
=IF(AND(F2="Yes",G2<E2),"Yes","No") to check if it can still be invoiced.
if you do want to use them then I'd recommend formatting your data as a table so that the formulas are copied down automatically on new rows.
Also I'd advise putting the index list on a different sheet so that rows are not deletes etc.
I have a table of data (Data!$A$8004:$F$10430) within an excel sheet which I need to search for all of the rows that contain the date displayed in cell: Data!Q27 (e.g may-2017) in column F of the table of data. And then output in a new table all of the rows which match that specific date (Data!Q27 changes, but is always in the MMM-YYYY format)
I created a similar solution for another table which worked, however for this data table it is not working. The working solution is shown below:
=IF(ISERROR(INDEX(Data!$A$1:$K$7523,SMALL(IF(RIGHT(Data!$A$1:$A$7523,7)=Data!$Q$25,ROW(Data!$A$1:$K$7523)),ROW(1:1)),1)),"",INDEX(Data!$A$1:$K$7523,SMALL(IF(RIGHT(Data!$A$1:$A$7523,7)=Data!$Q$25,ROW(Data!$A$1:$K$7523)),ROW(1:1)),1))
(This differs slightly as the date format in the table and Data!Q25 is /mmm/yy, but it successfully creates the new table which changes values dependent on the value in Data!Q25)
The format of the date in column F is e.g 09-May-2017 and is classified as 'general' type.
I have used this formula, and I get no error or value on the cell that this code is on:
{=IF(ISERROR(INDEX(Data!$A$8004:$F$10430,SMALL(IF(RIGHT(Data!$F$8004:$F$10430,8
)=Data!$Q$27,ROW(Data!$A$8004:$F$10430)),ROW(1:1)),1)),"",INDEX(Data!$A$8004:$F
$10430,SMALL(IF(RIGHT(Data!$F$8004:$F$10430,8)=Data!$Q$27,ROW(Data!$A$8004:$F$1
0430)),ROW(1:1)),1))}
The formula is formatted as an array, and therefore I believe this code should work, returning the first A column value of a row which fits the criteria of having, for example: "***May-2017" in its F column. However it doesn't.
Unfortunately due to corporate protection I am unable to share the spreadsheet, but if the information supplied in this isn't clear enough I could supply a new excel sheet to show my example?
https://drive.google.com/open?id=1NpS0_Bsy8XuicrPl8oy5tAswEa9QZ9X2 <- here is a spreadsheet that I have recreated to show the issue. The real spreadsheet is different, but this shows the purpose of my problem. Regardless of there being values which should be picked up on the tab names 'Data for normal user', no data is shown.
Thank you for your time!
Your formula is correct, however you haven't offset the rows.
Your INDEX() is starting at row 8 so this will be the first indexed row. SMALL() is building an array of the exact row numbers so row 8 in SMALL() is row 1 in the index, therefore no results are showing.
You simply need to update the IF() within SMALL() to handle this offset: (This formula has been updated to respond to formula dragging, i will include your original after)
=IFERROR(INDEX(ConfidentialLiveData!A$8:A$14,SMALL(IF(RIGHT(ConfidentialLiveData!$F$8:$F$14,8)=ConfidentialLiveData!$C$2,ROW(ConfidentialLiveData!$A$8:$A$14)-7),ROW(1:1))),"")
Or
=IF(ISERROR(INDEX(ConfidentialLiveData!$A$8:$J$14,SMALL(IF(RIGHT(ConfidentialLiveData!$F$8:$F$14,8)=ConfidentialLiveData!$C$2,ROW(ConfidentialLiveData!$A$8:$J$14)-7),ROW(1:1)),1)),"",INDEX(ConfidentialLiveData!$A$8:$J$14,SMALL(IF(RIGHT(ConfidentialLiveData!$F$8:$F$14,8)=ConfidentialLiveData!$C$2,ROW(ConfidentialLiveData!$A$8:$J$14)-7),ROW(1:1)),1))
A quick tip for error handling formulas is to use F9 when highlighting sections of your formula to show what that is calculating. For example i highlighted IF(RIGHT(ConfidentialLiveData!$F$8:$F$14,8)=ConfidentialLiveData!$C$2,ROW(ConfidentialLiveData!$A$8:$J$14)) and saw that that calculated as {8;FALSE;10;11;FALSE;FALSE;FALSE} so the match was being found just that the row numbers being returned were not what we were looking for.
Update:
So your formula is starting on row 8004, that row in the index is row 1. To get that row returned you need to take away 8003 from the 8109 to give you the 106th indexed row. A common way to do this is to take away the starting row and add 1 which in your original formula would be: {=IF(ISERROR(INDEX(Data!$A$8004:$F$10430,SMALL(IF(RIGHT(Data!$F$8004:$F$10430,8 )=Data!$Q$27,ROW(Data!$A$8004:$F$10430)-ROW(Data!$A$8004)+1),ROW(1:1)),1)),"",INDEX(Data!$A$8004:$F $10430,SMALL(IF(RIGHT(Data!$F$8004:$F$10430,8)=Data!$Q$27,ROW(Data!$A$8004:$F$1 0430)-ROW(Data!$A$8004)+1),ROW(1:1)),1))}