Problems Sorting in Excel - excel

I have read answers here to the question of sorting in Excel and having formulas not working. But the answers do not seem to help in my particular case.
I am a soapmaker and use Excel to calculate my recipes. The oils are listed alphabetically. I plug in the amount of oil I want to use.
I have formulas at the bottom of the spreadsheet to determine the ratio of solid oils to liquid and the ratio of some of the other oil combos.
Once I have the recipe I want to use, I want to sort the oils by quantity so that I can more easily make my labels, listing ingredients in order of amount used.
When I sort, the formulas at the bottom get all messed up. Putting $ in the formulas for the cell references does not help. I'm fairly Excel-savvy and that was the first thing I thought of.
I suppose could name the cells, but I have so many oils listed (30+) that that's prohibitive and I may add more in the future.
The calculations I want are quite simple yet I've tried all the methods I can think of and it's still not working. Help!

There are a number of solutions that could work, but as you've seen keeping static formulas below data you are sorting, is not usually going to work well. Here's something to consider:
If you can, ALWAYS group related data and formulas in a SINGLE ROW. This means for example, moving your formulas to the end of each row so they move around when the data moves around in sorting. Most people go wrong by trying to make it look pretty - but this is the most organized. Go for what's functional.
Your other alternative is to use Excel 2007+ tables (google search) - but I suspect from your description that you're pointing to specific rows and those can't be tracked without using VLookup. So that's your other alternative - Vlookup (google search - dozens of examples out there). You're basically writing a formula to dynamically find the correct row, no matter where it is (landed after sorting)
I really recommend my first option though, keep your formulas in the same rows. Hope that helps!

Move your data TO ABOVE the sort area. I do this when I have subtotals and other row based calculations, so that when I sort I don't have any issues.
I also suggest moving your label functions to a rank formula and use an Array formula to look up the unique combination, along with the Congatenate functions, so you don't have to worry about sort functions in your sheet.

Related

#VALUE using the FILTER function in Excel

I hear so many good things about the FILTER function in Excel, but I can't seem to get on with it. More often than not I end up with a #VALUE error. I'll usually get to the bottom of it, but this one has stumped me.
This is the formula:
=FILTER(Sheet1[#All],IFERROR((Sheet1[[#All],[Account]]=$D$1)*(Table2[[#All],[Duplicate 21711000]]=0),0))
I've put the IFERROR in because I thought perhaps a bunch of #N/A in the results could be causing an issue.
I've evaluated the Formula, and on the array on the Include side, everything seems to be working perfectly. The Boolean logic has worked, the 1s and 0s are in the right place to theoretically filter my list down to the few records I want to see. But when I click evaluate the final time, and it applies those 1s and 0s to the rows in the array, it results in the #VALUE error, and that's obviously all I can see in the cell.
Any ideas where I'm going wrong?
By the way, the point of this is to help a client who regularly pulls off a report from her accounting system, and then manually filters, copies and pastes the lines for new transactions onto separate tabs on her spreadsheet, over about 30 accounts. My plan is to use Power Query to bring the report into a tab in her spreadsheet, then use the Filter function to bring across the appropriate rows from the Power Query Table into each tab. That's the first criteria here.
I've created another table next to the PowerQuery table which uses a Count If to work out if that line has already been imported. So the second part of the criteria filters the list if the CountIf has registered a duplicate.
I can't just use PowerQuery everywhere, because she needs to then be able to add more columns and manipulate the data once it's been imported. So the final part of the job is to create a macro to copy > paste values, obviously copying the filter function into the row below first, ready for next month.
So Power Query imports all the data, Filter function extracts the specific data into each tab, and Macro locks in that data ready to be edited if need be.
If anyone can think of a better way of achieving the same result, I'm all ears.
So thank you #JvdV, the simple answer was indeed that the two tables were of different sizes, and FILTER requires for them to be the same size.
This caused a follow up issue though that in order to count if I had any duplicates in the sheet, I couldn't go with plan A and use a separate table, because it wouldn't dynamically change it's height when the Power Query table was refreshed.
I looked into maybe incorporating the table into the Power Query in the first place with a custom column. But this would mean that the PowerQuery would end up with 39 additional columns, which would all be brought across by each FILTER function.
So instead I did this. I know this is very niche, so probably won't help anyone, but I'm very proud of myself and want to post it somewhere:
=FILTER(Sheet1[#All],IFERROR((Sheet1[[#All],[Account]]=$D$1)*IF((COUNTIF('21711000 (125006) Int rec'!$C:$C,Sheet1[[#All],[Document Number]]))=0,1,0),0))
(I probably don't need the IFERROR anymore, but it works, so I'm not going to touch it, and it might be safe just in case there ever are any errors).
So this uses the fact that Excel spills now rather than needing specific array functions. Before I made COUNTIF into a separate column, but now I'm putting it in here, and it naturally spills in the background, essentially creating that column within the formula. Then the IF changes any 0 to a TRUE (1), and any other number (my duplicates) to a FALSE (0), and everything works.
It actually creates a circular reference, because the Filter is in column C, but I think that's okay for my purposes, because I don't want it to include the results from the filter anyway. I suspected that might happen, but it seems to be working so far.
I hope that can help someone.

Making an auto-updating list of goals sorted by difficulty

Project Details
I am currently making a checklist of long-term goals, each goal has difficulty self-assigned to it between 1 and 9, and I want to group these goals by difficulty, either in the one-column or in different tables.
As well as this, I've used a checkbox (Form Control) which I will tick once the goal is completed, which will put a strikethrough the goal as well as italicize it. The general idea is something like this. The goal cell is formatted when the corresponding checkboxvalue is TRUE.
My Issue
My problem is that when I want to add new goals to the list, I will need to manually move and adjust the goal list so that the goals are grouped by difficulty.
I would prefer to add goals to the bottom of the list and then use the sort tool to sort the table by difficulty (lowest to highest), or potentially find a way of adding the goal details to one table and it being grouped by difficulty automatically in another table.
Attempted Solutions
1. When I sort the table by difficulty, the correct goal cell is formatted but the checkbox does not move with the sort, ( Here I sorted from (smallest to largest) to (largest to smallest) to highlight the difference ).
I believed this was because I included the checkbox reference cell inside the table.
2. Knowing this, I moved the checkbox reference cells outside of the table. After sorting the table, the checkboxes now move to the correct cell, however the incorrect goals are crossed out. This makes sense, as the cells the goals are formatted on haven't moved.
3. Changing the reference from locked to unlocked (eg. =$D$2 to =D2 ) does not seem to change the result in either scenario. Neither does using a formula to populate the goal column based on another table containing the list.
Despite knowing all this, I have not been able to figure out a way to correctly move both the checkboxes via sorting, as well as correctly sorting the reference cell, thus the correct goal being crossed off. I suspect the solution will need
VBA code (which I have no experience in)
a smarter formula for conditional formatting
using ActiveX checkboxes (Which I would prefer not to)
potentially changing the layout of my whole list into separate same-difficulty tables.
Or something really obvious that I'm missing
Hopefully what I'm after isn't impossible, and any would be greatly appreciated.
Cheers :)

How do I sum several rows by category? (EXCEL)

I have created an excel sheet to have an overview over costs in my projects, however, I also need an overview of costs per category in my projects. I googled it and tried to find examples online, however, it only returns a value of 0, which shouldn't be the case. Can anyone help me? The sheet looks like below.
I am going by the SUMIF function to group by category but my excel sheet is a bit more complex than that so I tried to adjust it accordingly as seen in the code below. No matter what I do it either returns an error or 0.
=IF(B12=B8;"";SUMIF(B12:B39;B12;J12:BE39))
In the formula above I am trying to sum the costs of a category that could be written in B12, for example, Software development. For confidential reasons, I cannot show the actual filled out excel sheet.
sumif does not work with summing multiple columns. Instead use a sumproduct statement instead like so:
=IF($B12=$B$8;"";SUMPRODUCT(($B$12:$B$39=$B12)*($J$12:$BE$39)))
A detailed explanation to how this works can be found here
Edit:
I sense a follow up question coming, how to skip certain columns. Because as you have set it up now, it will count the entire range from J12 to BE39, in which you have both forecast costs and actual costs. I guess this is to compare the costs to what was projected and what the actual costs are. Right now it will count both the projected and actual cost, doubling up. To prevent this you can enter every second column separated by a + like so:
=IF($B12=$B$8;"";SUMPRODUCT(($B$12:$B$39=$B12)*($J$12:$J$39+$L$12:$L$39+$N$12:$N$39)))
Also I have added $ signs to all non-changing values so it will work when dragging down the fill handle on the formula to populate the below cells.

Match and lookup to find price

I would be grateful if someone could help with the following.
I have a workbook (called passenger car comparison) that has a column of postcodes (B1) and then columns for different prices (C1:I1).
In a separate workbook (called Search Tool), I would like to display the post codes from B1 as a dropdown list, with the same row also displaying the prices from C1:I1 for that particular post code.
Would I need to use INDEX and MATCH or HLOOKUP? Confused!
There is a link to the spreadsheet here if my explanation isn't clear!
Many thanks in advance!
You can actually use both.
However, you should use VLOOKUP instead of HLOOKUP, because your data elements are in rows, not columns. This is the most direct approach (=VLOOKUP(DropDown,WholeTableFromBtoI,Line,FALSE) - the FALSE here avoids linear interpolation with your postcodes). You can get your line from the row 1 of both cells, using MATCH, if you want to get fancy, by =MATCH(Category,FirstLineOfTable,0).
And, If you intend to use MATCH straightforwardly, your better approach would be using OFFSET as well, as in =OFFSET(FirstCellOfTable,MATCH(PostCode,PostCodeRow,0),MATCH(Category,FirstLineOfTable,0). It's a probably not the most intuitive approach, but it works as well.
Hope that helps.

Filter all unique items like Google Docs

Is there a quick/easy way to filter all unique items in an Excel 2013 column similar to the Google Docs "Unique" function?
This is not a pretty answer, but it works.
Paste this as an array formula into cell B2:
=LOOKUP(2, 1/((COUNTIF(B$1:B1, A:A)=0)*(A:A<>"")), A:A)
With the column that needs to be filtered in A:A
Then drag / copy it down as far as is required.
See it online in Google Spreadsheets
Caveats:
Does not retain original order (resulting order is in fact the reverse)
Does not automatically expand to cover all cells
Not fast, not pretty, not transparent
Footnotes:
It is trivial to use IFERROR() to filter out the #N/A errors, but I've not done this to keep the answer concise
In the same vein the header of the column A is currently also returned. This can be fixed by changing A:A to A$2:$25 in all 3 locations
Original question was for Excel 2013, all of this should work there, but I wrote and tested it in Excel 2016
I would love to hear suggestions on how to make the formula automatically expand down as far as required.
Use the Unique records only feature in Advanced Filter.
Under the DATA tab there is this: "Remove Duplicates". It'll do what you want.
There isn't an equivalent to =unique() in Excel, and I hate having to work without it.
Without =unique() trying to find all of the unique values in a large array of data is impossible. Take a dozen columns of a hundred+ entries and see what the unique values are across the whole mess and pop them nicely into a new columns. I can't figure out how to do it in Excel, but in Gdocs it's simple:
=unique(transpose(split(ArrayFormula(concatenate(A:M&",")),",")))
Using Filters, or PivotTables, or whatever, just doesn't cut it, and I haven't been able to find any hacked together ridiculous excel formula to do anything similar.
filter your data in spreadsheets
This might prove to be of some help to you.

Resources