Comments on: Pivot Tables the Hard Way -- Filling A Row With Column Data in Excel
http://ask.metafilter.com/356459/Pivot-Tables-the-Hard-Way-Filling-A-Row-With-Column-Data-in-Excel/
Comments on Ask MetaFilter post Pivot Tables the Hard Way -- Filling A Row With Column Data in ExcelWed, 04 Aug 2021 07:21:50 -0800Wed, 04 Aug 2021 07:34:06 -0800en-ushttp://blogs.law.harvard.edu/tech/rss60Question: Pivot Tables the Hard Way -- Filling A Row With Column Data in Excel
http://ask.metafilter.com/356459/Pivot-Tables-the-Hard-Way-Filling-A-Row-With-Column-Data-in-Excel
I have a workbook with an input sheet and then sheets showing different views of the data pulled from the input sheet. My primary views are fine, but for secondary views I need to fill output rows by reference to input columns. Due to Reasons, I think I need to do this with either INDEX, OFFSET or INDIRECT(ADDRESS...) rather than Transpose, or Pivot Tables. I can make INDEX work to fill across, but it can't be copied down.
Can you help me work around having to manually rewrite a formula for each ouput row? <br /><br /> I have a set of numbered Documents, and each of those Documents is related to multiple numbered Topics. <br>
<br>
I need to generate correspondence tables; i.e. one table that is indexed by Document number in the leftmost column, and shows all of the Topics a Document is related to on each row (the primary view), and another table that is indexed by Topic number in the leftmost column and shows all of the Documents related to that Topic on each row (the secondary view). <br>
<br>
I have entry set up so that there is a grid indexed (in rows) by Document number and with columns for the Topic number. Data entry is accomplished by filling the appropriate cells with "X"es and I have data validation set to display a dropdown of "X" and a blank. <br>
<br>
The primary output views are all working fine, as the input sheet is already indexed by Document number, allowing me to just concatenate and format the rows on the input sheet. <br>
<br>
For the secondary output, I need a formula that I can copy and paste to the right but that will read down along a column corresponding to a particular Topic number. i.e., I need the row number to increment when filling horizontally rather than the column letter.<br>
<br>
I understand that this is what Pivot Tables do (or part of what they do) but am under the impression that Pivot Tables are dynamic views that you switch between, which is not what I want to do. I want sheets that auto-update with all of the various views I will need and I never want to touch anything but the input sheet.<br>
<br>
I also know there is a <a href="https://support.microsoft.com/en-us/office/transpose-rotate-data-from-rows-to-columns-or-vice-versa-3419f2e3-beab-4318-aae5-d0f862209744">Transpose</a> function to cutting and pasting that seems like it's intended to do this, but it says it requires absolute references in the source range to preserve them and that seems like a problem here (although maybe I'm wrong about that). <br>
<br>
If the above is correct it seems to me my options are abusing some combination of the COLUMN function with INDEX, INDIRECT or OFFSET which so far as I can tell subverts Excel's normal behavior by using the inbuilt Column index numbers to forcibly increment relative references to rows when filling horizontally. In a way that makes my brains want to leak out of my ears. <br>
<br>
Here's how it's set up:<br>
<br>
The raw input data is pulled into the working sheet's range of D7:D56 (vertically as in the source).<br>
<br>
We are trying to copy that range horizontally into D64:BA64 for further concatenation and formatting.<br>
<br>
Currently I have one line of output working using INDEX. <br>
<br>
The first (upper left) output cell (D64) contains this formula:<br>
<br>
<code>=@INDEX($D$7:$D$56,COLUMN(A1),1)</code><br>
<br>
This works fine for the first row if I copy it across. <br>
<br>
However, due to the absolute cell references in the source, I can't just take D64:BA64 and fill down with it -- Row 65 needs to be filled with data from Column E, Row 66 from Column F, etc. <br>
<br>
The sheet is set up to support 250 Topic Numbers, and I do not want to hand-code 250 versions of this formula and fill each row manually if I can all avoid it. <br>
<br>
I understand there are ways to do this using OFFSET or INDIRECT(ADDRESS...) but trying to get my mind around that is really hurting my brain more than INDEX did. <br>
<br>
Is there some way I can hack my way around this by more programmatically assembling the INDEX function? Or can someone explain how I would do this with OFFSET or INDIRECT in a way that I can do this with two copy/paste operations (i.e. one to fill the top row, then one to copy the top row down). <br>
<br>
(Or am I mistaken about being unable to use Pivot Tables or Transpose for this?)post:ask.metafilter.com,2021:site.356459Wed, 04 Aug 2021 07:21:50 -0800snuffleupagusExcelspreadsheetdatatablespivotpivottablesdataanalysisexcelformulaBy: snuffleupagus
http://ask.metafilter.com/356459/Pivot-Tables-the-Hard-Way-Filling-A-Row-With-Column-Data-in-Excel#5091462
Some of the more helpful references/threads I've consulted so far (in addition to the Excel docs and the MS helpsites):<br>
<br>
<a href="https://www.journalofaccountancy.com/issues/2017/jun/excel-reference-vertical-cells-horizontally.html%20(INDEX%20method)">Microsoft Excel: How to reference vertical cells horizontally</a><br>
<br>
<a href="https://www.brainbell.com/tutorials/ms-office/excel/Make_Your_Formulas_Increment_By_Rows_When_You_Copy_Across_Columns.htm">Make Your Formulas Increment by Rows When You Copy Across Columns</a><br>
<br>
<a href="https://superuser.com/questions/231681/excel-help-fill-tool-drag-to-the-side-across-columns-but-increase-the-formu">Excel Help: Fill Tool - Drag to the side (across columns) but increase the formula by Row Number</a><br>
<br>
<a href="https://superuser.com/questions/946545/how-to-fill-formula-horizontally-but-increment-cell-references-vertically">How to fill formula horizontally but increment cell references vertically</a><br>
<br>
<a href="https://superuser.com/questions/854124/excel-copy-formulas-horizontally">Excel Copy Formulas Horizontally</a><br>
<br>
<a href="https://webcache.googleusercontent.com/search?q=cache:hzIrJDpy2O8J:https://www.listendata.com/2013/06/two-ways-to-increment-formula-row-when.html+&cd=1&hl=en&ct=clnk&gl=us">Two ways to increment formula row when copied across columns in Excel</a> (G-cache link)comment:ask.metafilter.com,2021:site.356459-5091462Wed, 04 Aug 2021 07:34:06 -0800snuffleupagusBy: bbqturtle
http://ask.metafilter.com/356459/Pivot-Tables-the-Hard-Way-Filling-A-Row-With-Column-Data-in-Excel#5091465
Hi Snuffleupagus!<br>
<br>
I do this kind of work all the time. I know you said you are limited to those functions, but would it be possible to accomplish your goals with Sumifs and xlookups? Sumifs show values based on multiple criteria, and xlookup is the same as vlookup but can be used in either direction. Sumifs also seamlessly transitions from rows to columns without hesitating.<br>
<br>
I also am a power user that creates sheets similar to yours, and I'd say 90% of the data is filled with sumifs. Text data is usually filled with xlookup, though with multiple criteria I need to get fancy.<br>
<br>
With sumifs, you just fill in your reference rows and columns at the top and left of the data, and write the formula so it dynamically fills in the results. That seems to be the tool missing from your toolbox to solve this problem. I'd be happy to elaborate if helpful. <br>
<br>
Though, if you exceed, say, 10,000 rows, sumifs can crash your excel. Always test with a small selection first.comment:ask.metafilter.com,2021:site.356459-5091465Wed, 04 Aug 2021 07:42:11 -0800bbqturtleBy: bbqturtle
http://ask.metafilter.com/356459/Pivot-Tables-the-Hard-Way-Filling-A-Row-With-Column-Data-in-Excel#5091466
On Transposing formulas:<br>
<br>
One useful thing you can do is transpose references. So if you take a selection, and copy and "paste links" it is a link to all of those cells. But, you can't do that and transpose at the same time.<br>
<br>
So, the hack I use (I'd like to say I discovered it, but I'm sure others have a way as well) is you can "paste links" normally, then find and replace "=" with "#", which makes all of the cells no longer formulas. Then, copy the "#"-ated cells, and transpose. Then, find and replace # with "=".comment:ask.metafilter.com,2021:site.356459-5091466Wed, 04 Aug 2021 07:44:33 -0800bbqturtleBy: bbqturtle
http://ask.metafilter.com/356459/Pivot-Tables-the-Hard-Way-Filling-A-Row-With-Column-Data-in-Excel#5091468
A few other notes on further inspection:<br>
<br>
Sumifs could reference the document number as well. Lock that reference! <br>
<br>
Use 1's or 0's instead of X's. That was it will work in sumifs/pivot tables much better.comment:ask.metafilter.com,2021:site.356459-5091468Wed, 04 Aug 2021 07:47:40 -0800bbqturtleBy: snuffleupagus
http://ask.metafilter.com/356459/Pivot-Tables-the-Hard-Way-Filling-A-Row-With-Column-Data-in-Excel#5091475
Looking into sumifs/xlookup as well as the paste links thing. <br>
<br>
I suspect it would be as fast for me to use a temp sheet to build another 249 versions of the INDEX formula I can cut and paste in and then manually fill each row as to learn vlookup/xlookup, if a lot more tedious, but we'll see. It's worth learning if I can puzzle it out.<br>
<br>
I want to keep the input sheet as Xs and blanks for clarity and ease of use, by the time the data hits the secondary view sheets it's working with numbers. (Like so: <code>=IF(Input!D10="X", $A8, "")</code> with the numbers statically populated in the A column).<br>
<br>
I'll see what I can work out. Will report back. Thanks!comment:ask.metafilter.com,2021:site.356459-5091475Wed, 04 Aug 2021 08:02:59 -0800snuffleupagusBy: bbqturtle
http://ask.metafilter.com/356459/Pivot-Tables-the-Hard-Way-Filling-A-Row-With-Column-Data-in-Excel#5091500
The amount of effort you are putting into this sheet is pretty irregular from a normal business perspective. There's probably a different, faster way to accomplish this goal. I deal with these types of workbooks a <em>lot</em>, and I'm having trouble wrapping my head around the application of it - unless you need to upload it into some ancient system. Having 250 sheets in a workbook is not how sheets are intended to be used typically.<br>
<br>
A few possibilities that I've used before:<br>
<br>
Could all of your data live on one sheet, and you just use a filter?<br>
Could you use a dynamic sumifs, with references to dropdown-menus at the top, to allow the end user to select their index, then it auto-populates? Like, typically I would have one sheet full of data, and then your "secondary view sheet" is the second sheet, just populated through sumifs. Sometimes I have an intermediary sheet.<br>
<br>
It would be really helpful if you had a version of the sheet you could share to explain - with what the input and output looks like.comment:ask.metafilter.com,2021:site.356459-5091500Wed, 04 Aug 2021 09:45:39 -0800bbqturtleBy: snuffleupagus
http://ask.metafilter.com/356459/Pivot-Tables-the-Hard-Way-Filling-A-Row-With-Column-Data-in-Excel#5091528
I'm sure you're right. (But that's 50x250 columns/rows depending on the orientation, not 250 sheets.)<br>
<br>
Like a lot of things, the better way is faster if you know what you're doing. However, learning the better way can be slower. Like, weeks, months, years. <br>
<br>
I spent about thirty minutes reading about XLOOKUP (and its forerunners) and realized it's probably the Right Way to go about this, but also that it would take me a couple days to work out how to do it properly. Figuring out how to get OFFSET or the INDIRECT(ADDRESS....) hacks to work would likely be quicker, but is just scrambling my brains at the moment too. <br>
<br>
Meanwhile, the cut and paste trick got me thinking that I could probably work out a quick and dirty way to programmatically build all the formulas I needed (like the way you would munge text in a Bash pipeline) in another workbook but with the output using a leading # instead of =@, then copy and paste the resulting cells as values into the sheet doing the column-->row conversion, and find and replace the # with the =@.....<em>et voila</em>.<br>
<br>
So now I have CorrespondenceTableColumnMunger.xls hanging out alongside my main workbook. This is of course Ugly and Wrong but it's Good Enough and Working Right Now, and the horrible parts can be replaced with something more elegant later. <br>
<br>
The main use case is responses to Requests for Production under the<a href="https://www.resolvingdiscoverydisputes.com/request-for-production-of-documents/make-sure-you-are-aware-of-the-new-document-response-requirements/"> California Code of Civil Procedure</a>. There is a revised requirement that the materials produced must be correlated with the requests they are responsive to (and any one document/exhibit is going to be responsive to more than one request). You can't just do an undifferentiated doucment dump anymore. And if I have to generate a table indexed by Exhibit Number, then I'd also like to be able to generate a table indexed by Request Number. <br>
<br>
I also have call to produce correlation tables of numbered documents and their topics for other work purposes. <br>
<br>
I can upload the files (or some illustrative screenshots) if anyone really wants to see my hackery, or if the Munger might be of some use to others -- but it might give you the Brain Worms.comment:ask.metafilter.com,2021:site.356459-5091528Wed, 04 Aug 2021 11:26:00 -0800snuffleupagusBy: soelo
http://ask.metafilter.com/356459/Pivot-Tables-the-Hard-Way-Filling-A-Row-With-Column-Data-in-Excel#5091560
This is a many to many relationship and is one of the times that using a database is much faster than using Excel, but as you said, that has a learning curve and if this is a one time thing, not worth the learning time. But it sounds like this request may recur, so here goes:<br>
<br>
In a correctly designed database, you would not have a table with every document as rows and every column as a topic and then only put an X in the cells that are "Yes". You would have one table with two columns: Document and Topic. Then you populate the rows with only the Yes values. So, instead of a 50x250 cell table, you have a table that can be thousands of rows but is still just two columns, which is much easier to query.comment:ask.metafilter.com,2021:site.356459-5091560Wed, 04 Aug 2021 12:52:07 -0800soeloBy: snuffleupagus
http://ask.metafilter.com/356459/Pivot-Tables-the-Hard-Way-Filling-A-Row-With-Column-Data-in-Excel#5091574
Yes. This is an area that I'm relatively weak. I know what databases are for, and I know some basics as required for sysadmin tasks I've peformed, but I have no actual DBA skills. Which is why I'm using Excel instead of Access, and why I fell back onto what I do know, from text pipelining, cascading references, basic array manipulation and so forth. <br>
<br>
I suppose what I've created is something like a kludged set of linked lists, which I suppose isn't so horrible a structure for this in the abstract. <br>
<br>
But it's pretty<a href="https://i.ibb.co/BgSzjfW/RFP-Correspondence-Table-Hackery-B.png"> horrible as executed</a> (some snips as a single image)<br>
<br>
Nonetheless, done is done.comment:ask.metafilter.com,2021:site.356459-5091574Wed, 04 Aug 2021 13:11:17 -0800snuffleupagusBy: snuffleupagus
http://ask.metafilter.com/356459/Pivot-Tables-the-Hard-Way-Filling-A-Row-With-Column-Data-in-Excel#5091580
<a href="https://i.ibb.co/BgSzjfW/RFP-Correspondence-Table-Hackery-B.png">Corrected image</a> (it was showing a value instead of its formula).comment:ask.metafilter.com,2021:site.356459-5091580Wed, 04 Aug 2021 13:28:37 -0800snuffleupagusBy: bbqturtle
http://ask.metafilter.com/356459/Pivot-Tables-the-Hard-Way-Filling-A-Row-With-Column-Data-in-Excel#5092003
Well, I'm glad you found a solution! Your images don't work, but that's okay. I hope you learned a few nuggets, and next time things will be even easier!<br>
<br>
I agree with Soelo that a database would be easier, but the crucial part of what he said was trying to have only one column with the data in it. You can do this in excel too. So instead of a workbook having:<br>
<br>
xxxxxxxxxx Date1 date2 date3 date4<br>
location1<br>
location2<br>
location3<br>
location4<br>
<br>
With X's location for data, it's much for efficient to have<br>
<br>
location 1 date 1 X<br>
location 1 date 2 X<br>
location 1 date 3 <br>
Location1 date 4<br>
location2 date1<br>
location2 date2<br>
location2 date3X<br>
<br>
etc.<br>
<br>
If you start from this position it's much easier to reference and work with. Sumifs / xlookups / nested lookups / concats can reference the combination of columns much easier than searching within a range.comment:ask.metafilter.com,2021:site.356459-5092003Thu, 05 Aug 2021 09:46:39 -0800bbqturtleBy: snuffleupagus
http://ask.metafilter.com/356459/Pivot-Tables-the-Hard-Way-Filling-A-Row-With-Column-Data-in-Excel#5092033
Weird. I must have the one I deleted cached. How bout <a href="https://i.ibb.co/jWbBxM3/RFP-Correspondence-Table-Hackery-B.png">this</a>? <br>
<br>
Thank you <em>very much</em> for this:<br>
<br>
<em>So instead of a workbook having:<br>
<pre><br>
xxxxxxxxxx Date1 date2 date3 date4<br>
location1</pre><br>
<br>
it's much for efficient to have<br>
<pre><br>
location 1 date 1 X<br>
location 1 date 1 X<br>
location 1 date 2 X<br>
location 1 date 3</pre></em><br>
<br>
That crystalizes the thing about having two columns rather than intersecting rows and columns in a way that the DB basics hovered in the hobbyist-level coding tutorials I've done never have.comment:ask.metafilter.com,2021:site.356459-5092033Thu, 05 Aug 2021 10:43:12 -0800snuffleupagusBy: bbqturtle
http://ask.metafilter.com/356459/Pivot-Tables-the-Hard-Way-Filling-A-Row-With-Column-Data-in-Excel#5092202
Oh jeez you're really in the weeds on this one. If I was your coworker and you could share screens, I'd have you scrap this thing entirely and try to remake it from scratch, skipping like 4 steps hopefully. But! If it works, it works!<br>
<br>
I'm still not totally understanding things, but I'm happy I can help. Honestly, sumifs/xlookups work so well that I've never had to go down the rabbit holes you have. If you ever need more excel help, I'll always be around!comment:ask.metafilter.com,2021:site.356459-5092202Thu, 05 Aug 2021 17:49:44 -0800bbqturtle