Horizontal reference not working in excel - excel

Below there are two pictures of tables
vertical table is Temp data 2014.xlsm
horizontal table is Overview_allcities 2014.xlsm
I want to quickly setup the values in the horizontal table using the auto fill.
The value of C34 in the horizontal table is
=IFERROR(IF(MATCH('[Temp data 2014.xlsm]Harrison'!$A$2,A1,0)=1,'[Temp data 2014.xlsm]Harrison'!$D$4,""),"--")
Now when I drag it to the right I want to increment it to "$D$5" i.e.
=IFERROR(IF(MATCH('[Temp data 2014.xlsm]Harrison'!$A$2,A1,0)=1,'[Temp data 2014.xlsm]Harrison'!$D$5,""),"--")
I tried using changing the references to absolute and relative. None would do this step automatically.

Not-so out of the box idea here. Have your tried doing it with INDIRECT() ?
In my head I'm thinking something like this in the horizontal table:
You could use COLUMN() to create a moving variable. You in this case C34 - B would be 1, then +3 offset to get 4. Merge those together into a text string and you'd get a $D$4, then $D$5, and so on.
"'[Temp data 2014.xlsm]Harrison'!$D$" & COLUMN() - COLUMN($B:$B) + 3
Then implement it into the formula using INDIRECT().
=IFERROR(IF(MATCH('[Temp data 2014.xlsm]Harrison'!$A$2,A1,0)=1,INDIRECT("'[Temp data 2014.xlsm]Harrison'!$D$" & COLUMN() - COLUMN($B:$B) + 3),""),"--")
Now, I'm 100% grasping at straws here since I've only quickly tested this but I'm quite certain it could prove useful.
Let me know if it works, or not. Might have to work out a few kinks!

Related

Aligning vertically a series of tables with text

Hi I need the text to be in a specific format in a spreadsheet to be able to upload it on a translation tool.
I have already used the text split function to separate the text in a cell with bullet points, moving each bullet point to a separate cell.
enter image description here
Then I used the transpose function to separate each set of data. For context, you are looking at fashion products.
The name of the product is on the first row, followed by a list of features (e.g. "Bracciale" means bracelet and it is followed by the list of materials)
enter image description here
Now for the last step, I need these sets to be vertical, not horizontal. Like this:
enter image description here
I would like to set up an automatic system so that every time we receive a list with hundreds of these products we do not need to copy-paste them one below the other.
With pivot tables maybe? Keep in mind that if it is too complex it might be hard to train the translators to do it each time. Please let me know your suggestions. Thank you!
I am not a programmer. I tried pivot tables but the data was in the wrong order and I am not sure how to get the data out from the pivot table with values only without the sub-menus.
My suggestion would be to use the 'Unpivot Columns' feature in the Power Query Editor - it would be really simple.
Steps:
Select the whole range
Go to Data // Get & Transform Data // From Table/Range
Uncheck 'My Table has headers' (unless it does - but doesn't look like it?)
Press OK. This will open Power Query Editor and will have actually given you column names Col1/2/3 etc, but ignore that.
Go to Add Column // Index column
Select all columns EXCEPT the new index column by Shift+clicking on those headers
Go to Transform // Unpivot Columns
Assuming the order is important, click in the Attribute column and Sort Ascending
Click in the Index column and Sort Ascending
Remove the Attribute and Index columns if you want (right click header)
Go to File // Close & Load
You will get a new table - dynamically linked to the first (ie. can be updated/refreshed) - in the unpivoted format.
Let me know if you need more details / screenshot?
Based of this trick, maybe the following is helpfull:
Formula in A5:
=DROP(REDUCE(0,A1:A3,LAMBDA(a,b,VSTACK(a,TEXTSPLIT(b,,HSTACK(CHAR(10),"^"),1)))),1)
TEXTSPLIT() will use a combination of newline chars and the circumflex to split the input directly into a vertical array;
Iteration in REDUCE() will allow for stacked results;
DROP() the initial value from results.

EXCEL: How to automatically add serial number in Excel Table using formula that is immune to filtering / sorting?

I want to create an Excel Table where the first column is the "SL" (serial number) column that starts from 1 and then increases by 1 for each subsequent entry. I want the serial number to automatically increase as I add more rows to the table.
I have tried using all manners of "=ROWS" functions, all manners of "=COUNTA" functions, and all other functions used in tutorial that I found in the web. None of them are immune from sorting or filtering. That is, if I sort the "Name" column from A to Z, the serial number that was assigned to its respective row entry changes because of how these formulae are written. For example:
This is the Original List. As you can see, Dragon Fruit's serial number is 1. I have used the "=COUNTA(B$2:[#[NAME]])" function in this example.
As you can see, when I sorted the "Name" column from A to Z, Dragon Fruit's serial number went from 1 to 2, Acai went from 4 to 1, Guava went from 9 to 3, and so on. But I want the serial numbers to be static and locked to their corresponding "Name".
Is this possible to do in Excel without manually typing the numbers in the SL column?
Good question and a tricky situation to deal with. I'm not sure if the question is better suited for SuperUser though.
The trick here is to somehow use absolute cell-references instead of relative ones. As you have now experienced, Excel filters won't work well with relative references. However, manually adding absolute references is not what we want to do.
To mimic the absolute cell-reference behaviour you can preceed the row reference with a sheet-reference which magically should counter the normal formula-behaviour and turn them into actual absolute cell-references:
Formula in A2 (which will auto-fill the 'SL' column):
=ROW(Sheet1!A1)
Data when filtered A-Z on 'Name':
Data when tabbed a new row:
You could use PowerQuery in Excel to add an index in front.
Remove the ID from your source.
Make your source a table
Import into PowerQuery and add an index
Load the output to another sheet. In this sheet you can filter and sort and everything you want.

Excel - calculate quartile and median to generate box plot given a list of values and counts

I have a rather simple task to achieve but I am not sure how to do that in excel.
I have a list of values and number of counts of each value (my variable is discrete). I am trying to calculate 1st and 3rd quartiles of the variable given the counts I have. Overall dataset will be too large to fit into excel in raw format so I am using matrix of value counts.
Example:
Value | Count
1 | 100000
2 | 300000
3 | 350000
4 | 100000
5 | 50000
6 | 1000
7 | 10
I need to generate 1st, 3rd quartile and median out of this dataset, but as far as I see excel's quartile accepts only raw values, not values and their counts.
Assuming the table as you give it is in A1:B8 (with headers in row 1), for the median you can use the following array formula**:
=SUM(LOOKUP(INT(SUM(B2:B8)/2+{0.5,1}),MMULT(N(ROW(B2:B8)>=TRANSPOSE(ROW(B2:B8))),N(+B1:B7))+1,A2:A8))/2
Note the one offset range (B1:B7) here, where B1 is assumed, as mentioned, to contain a (text) header.
Edit: Re quartiles, that would depend on whether you are wishing to calculate these as per the Excel QUARTILE function or as per their 'standard' definition, i.e. as medians of the upper/lower half of the data (see here).
Regards
**Array formulas are not entered in the same way as 'standard' formulas. Instead of pressing just ENTER, you first hold down CTRL and SHIFT, and only then press ENTER. If you've done it correctly, you'll notice Excel puts curly brackets {} around the formula (though do not attempt to manually insert these yourself).
I dont think this is possible only using formulas. You can easily create formulas to have the separate lists to avoid problem of having more total lines than excel rows, but I dont know about any way to append these lists into one big list inside functions. MAybe someone else knows a way, but in the meantime there is another way in Excel:
What you can use is power query and power pivot. You start with the table that you have and add it as to Queries (Data - "Get & Transform Data" section - "From Table/Range". I have Excel 2016 so if you have a different version the path is most probably different or in older versions these tools are not available)
Now edit the query and add another column using List.Repeat to create your full dataset, expand the values and load to data model (when you are in Query Editor go "Home" - "Close & Load", click the small arrow down and select . "Close & Load To..." and select "Only Create Connection" and check "Add this data to the Data Model")
Inside the "Power Pivot" tab you can add a new Measure to calculate the quartile for this table. I used
quartile:=PERCENTILE.EXC(AllData[AllValues];0,25)
as I dont think there is really special quartile function.

How to scrub data in Excel, specifically removing extreme outliers that are outside of a given range?

I have thousands of cells of data that are output from a model, with my results formatted as follows: cell ID is column header, each row is a timestep, and each cell's results over hundreds of timesteps is printed out in a spreadsheet. I want to analyze the data within certain percentiles. I've identified what the values are for the percentile thresholds of interest, but I'm not finding clear directions on how to ...
a) remove all values that are outside of the range I'm interested in, for the sheet I'm working in
or
b) pull the values within the range of interest out of the sheet and into a separate one for further analysis
The values are numbers with two decimal places.
I need to scrub the data, then analyze it, in a separate step. For example, even after removing the extreme max and min in a timeseries, I still want to see the entire timeseries but with the outliers removed or changed to a null value. How can I select or simply remove all the outliers from this data matrix, leaving the rest of the data in tact?
The best way to do it is using the PivotTable feature.
With the PivotTable you will be able to create filter parameters using ranges (the main data and the outliers as well).
Please, take a look on this if you don't know how to use a PivotTable:
Create a PivotTable to analyze worksheet data
Although "Robust" the easiest way to do this would to to filter your data. After that, filter out all of your good values. Once you only have the "bad" cells visible, then go to special and highlight only visible cells. From there, delete.
To do this efficiently / with keyboard shortcuts, it would be like so:
1) Select the data headers and type alt + h + s + f
2) Click the "value" header, and click proper numbers until you have all the data you do not want filtered out.
3) Highlight all of the remaining cells (These should be the data points you want deleted, and the row numbers in excel should be blue now)
4) Type alt + h + f + d + s + y to go to special and select visible cells only
5) Type alt + h + d + r to remove the rows (this will take a bit of time, be patient)
I hope it works!
***EDIT: Instead of manually sorting out the data, you can also rank based off of size, and directly cut the data like that. After thinking more about the answer, this method would be easier (I think) and much faster.

Excel formula referencing it's own column

I have the following data set:
Name Class Amount Position
1 I1 A 10 P
2 I1 O R
3 I1 A -5 R
4 I2 O P
5 I2 A 7 P
6 I2 A -11 R
Typically Amount has missing data. I want to populate the missing data from records that match my record on Name and Position . So in Row-2 I want -5 and in Row-4 I want 7. If I combine Name and Position to create a Key-column then I can do an index match or vlookup or just to an index-match with multiple criterion.
What I want to know is what is the most sensible way to go about it?
Do I create a new column, say Amount-2 and write a function in it that pulls up data from Amount and does a index-match if it is missing? I don't want to do this because I don't want to add more columns to my dataset.
Should I sort the dataset on Amount so I can bunch up all the blank cells together on top and write a formula in them referencing the populated cells below in the same column? Is this method going to be robust to later sorting the data set on other fields or will my formula references go haywire?
Write a macro that populates the missing cells? Overkill?
The reason I ask is that I don't want to make my sheet bigger by adding more columns like Key or Amount-2 and I wanted to know what is a robust and clean way to fill in the gaps.
Pros - Nice and simple, guaranteed to work with no surprises.
Cons - Adds to dataset.
Pros - avoids adding to dataset
Cons - sounds a bit convoluted to me, sorting may be an issue, though adding a copy/paste values would mitigate.
Pros - you've got VBA, you can do whatever you want, no extra columns or cutting/pasting required.
Cons - If you're not conversant with VBA, could be a (small) challenge to write. Could require that new users are trained.
My personal thoughts here are to just go ahead and write a macro. Even if you're not VBA savvy, using the macro recorder, then going through your option #1 (deleting the column at the end of the procedure to avoid the extra field) would get you a long way in this particular instance. You definitely want to go in and clean up the code afterwards, but you'd be quite a bit of the way there.
Map that macro to a shortcut, and updating your new data will be a trivial task.

Resources