Excel "SMALL" "IF" another row is not blank - excel

I try not to ask for help like this but this one is screwing my noodle.
I have a costing spread sheet that I have managed to manipulate to give me a monthly cost role up (if exists) VS part number. Part numbers column c, months row 3.
On another sheet I'm trying to list the part numbers next to the cost role up and relevant date (each part number may have multiple entries)
I just need to do a "SMALL" for the "date" row (Row 3) on my costing sheet "IF" the "correct part number row" (or a fresh MATCH/VLOOKUP for the part number) has data in it. Or some how have the small return the Column INDEX number. I could then use INDEX to return the correct date and value using SMALL and Column B (the number of costs per part number, so if there are 3 instances that column currently list 1,2,3 before starting the next part number)
So close..... but this last bit is a struggle. Its a shame SMALL cant return INDEX Column numbers.
Does anyone know how to get a "SMALL" to lookup a row (based on a column search criteria) and check if the column has data, if so include the that column header in the "SMALL"
Update...
Thanks for your comments. I've stripped out the problem into a separate sheet to make it a little clearer. (I'll upload if possible).
I've also completed the rest of the excel to show the whole process. In doing so I've discovered Headers are automatically converted to text and so added a column to work around this using "DATEVALUE".
The goal is to list the number of costs related to a part number so.... if 500111 has had a cost role up in 3 different months it will list them in the cost report. So.... part number, relevant column "date" from "Cost data" sheet and relevant cost (#that part number # that date). if I can get a list of dates from "Cost Data" columns and put them in Column D "Costing date (text)" next to the relevant part number i should be sorted. I've highlighted the column in red on the new screen shots.
Cost Report
Cost Data
lines highlighted in yellow just to show they are empty
Edit:
Almost there for anyone else trying this
=INDEX($B$5:$J$5,,SMALL(IF($B$6:$J$6>0,COLUMN($B$6:$J$6)),3))
I just need to figure out how to define a variable "ROW" within a SMALL(IF statement. I should then be able to reference the correct table row number (which I already have).
Anyone know how to put a variable ROW or COLUMN reference in a SMALL formula?

Did not understand the problem fully.
But like this you can have a variable Row in the small formula:
=SMALL($A$4:$A$10;ROWS($C$4:C4))

Related

Google Sheets: Searching List for Most Recent Passed Value as Sum Increases

my family and I are doing a challenge to run the distance from one city where my siblings live to another. We have a google form set up in order to log our runs and distance, and then I put in a simple sum formula to show our current total progress. However, I would like to add in a feature on the spreadsheet to show our current location on the "run".
I was able to come up with a list of the cities we would pass through along with the distance to those cities, however I would like the sheet to update to indicate Current Location: "city" when we pass through one of them.
Ideally, this would mean I could input a formula that searches the list of cities (in a second sheet tab), and then identifies when the sum surpasses one of the listed distances, and then returns the names of that most recent surpassed city. I have a copy of the sheet below.
Copy of sheet (personal data removed)
I've tried something along the lines of =INDEX(G:G,MATCH("zzzz",G:G)) for inserting the cities manually as we pass them in column G, but I would need to be constantly updating the sheet on my own in that case. I would be putting the formula in H1 of the form tab.
Hoping this is possible, appreciate any help!
In H2:
=ArrayFormula(IF(B2:B="",,VLOOKUP(SUMIF(ROW(E2:E),"<="&ROW(E2:E),E2:E),{Cities!B:B,Cities!A:A},2,TRUE)))
The first IF test leaves the Col-H row blank if the corresponding row in Col E is blank.
SUMIF returns the sum up to the current row at each row in Col E.
VLOOKUP looks up each of those progressive sums within a virtual array of the data from your 'Cities' sheet in reversed order and returns the second virtual column (which turns out to be your city name). Because all values in Cities!B:B are in perfect ascending order, the final parameter of VLOOKUP can be set to TRUE, which will return the closest value before the searched value if an exact match is not found.
In your example, you can use index match cities and sum running sheet with fixed first row to achieve your outcome, here is my solution:
=index(Cities!A:B, match(sum($D$2:D2),Cities!B:B,1),1)

Getting Top Values from One Sheet and inputting onto a different sheet

So I'm going to eventually have 3 sheets. Sheet 1 is where I have data (numbers for a category and a name associated with it. Sheet 2 is where I pull the top 5 users for each category. Sheet 3 is where I have a leaderboard for points gained.
Right now I'm trying to work with Sheet 2 (grab the top 5 performers from each category. I'm fairly new to Excel, but after some research it seemed that XLOOKUP would be the way to go. (i'll attach screenshots below.
I'm using this formula:
=XLOOKUP(LARGE('Cases Test for Categories'!$C$18:$C$55,1),'Cases Test for Categories'!$C$18:$C$55,'Cases Test for Categories'!$A$18:$A$55)
however when using it I get all 0's.
Here's a screenshot of values I'm trying to grab from "Warranty Service Request"
and here is a screenshot when applying my formula
The solution I would want is to grab the 5 largest numbers from sheet 1 with the person name as well.
I don't think that XLOOKUP can get you anywhere near what you want but the formula below will get you one step closer.
=INDEX(List,MATCH(LARGE(INDEX(List, ,2),1),INDEX(List,,2),0),1)
In fact, it's the explanation of that formula which will be of help. Here we go.
List is a named range, perhaps equal to your 'Cases Test for Categories'!$C$18:$C$55. The reason for using a name is obvious. It's shorter. In my test List = A2:B6, in case you want to reconstruct it. Column 1 has names, column 2 numbers.
The term INDEX(List,,2) specifies the second column of List. You can replace the '2' with a formula to specify different columns of the named range.
In fact, INDEX(List,,1) does specify the first column and INDEX(List,4,1) specifies the 4th cell in that column, and that is exactly what you see in my formula. All of MATCH(LARGE(INDEX(List, ,2),1),INDEX(List,,2),0) just serves to find the row number in List, in this example the number 4.
Of course, LARGE(INDEX(List, ,2),1) returns the largest number in column2 of List. The '1' can be replaced by a formula, for example ROW()-1 which would return 1 if placed in row 2 and count up from there as it's copied down. Try =ROW()-1 in any cell in row 2 and copy the formula down.
MATCH([LARGEST],INDEX(List,,2),0) returns the row number where the largest was found, and that is the number we need to return the name from the first column of List.
This will work perfectly for one column and can easily be modified to work for different columns. Your question doesn't specify how you would like to arrange the 5 results from each category but the formula can be modified a little to accommodate whatever you want. What it can not do is to deal with ties. MATCH(LARGE can only find the first of several identical results.
To break ties in this sort of operation is complicated and must be done ether by helper columns in the data table or using VBA. It's definitely the topic of another question. For now I hope that it's a problem you will not have to anticipate.

Production Calendar - Excel

I always bite off more than I can chew when it comes to my Excel knowledge. I am hoping someone could help me with this.
Essentially, I have two sheets, first is "Schedule" which is a data dump from MYOB with what we have on order with the warehouse to produce.
I then go through and plan what needs to be made on what day over a two week period.
I'd then like this to be put in a user friendly calendar in "Plan".
I thought of doing a comcatenate to make the week and day unique, and used an IF And formula. Then i realised all I am doing is making it look for the first line.
Is there a way to do what I am asking in Excel?
I guess what I want the calendar to look up a category, EG DUCT, then place anything with Duct in the respective concatenated calendar line.
spreadsheet can be found here
http://www.castekauto.net/stack/PlanningSchedulestack.xlsx
TIA
After some changes to the planning table which include:
Filling column A with Week-Day
Unmerging the column headers (for Duct for example)
Standardizing the fields you need (Composite Hose changed to Hose for example to match the Schedule worksheet)
I used the following array formula (entered with Ctrl+Shift+Enter):
=IFERROR(INDEX(INDIRECT("Table3["&C$6&"]"),SMALL(IF((Table3[Helper]=PLAN!$A7)*(Table3[STOCK CATEGORY]=PLAN!C$5),ROW(Table3[ITEM CODE])-8),ROW(7:7)-MATCH("zzz",$B$1:$B7,1)+1)),"")
Sample workbook uploaded here.
A bit of mumbo jumbo if you want to understand the formula break down a bit:
IFERROR(Result, "") simply will show blank if the result is an error (there are no more items that can be displayed)
INDEX(Column Result,SMALL(Matches, N)) Here Column Result is where the result of what we need comes from. It can be Item Code, Description or Quantity. Matches is a list of index for the rows that matched some specific criteria (Type of material, whether it's in the same week and day) and N is the Nth result we need. If N is 1, then we get the first result of the matches, if N is 2, we get the 2nd.
From the above, I used INDIRECT("Table3["&C$6&"]") for the Column result to make the formula a bit more flexible. When it is like this, the formula will decide which column it needs to return, whether it's the Item Code, Description or Quantity.
Matches is defined by IF((Table3[Helper]=PLAN!$A7)*(Table3[STOCK CATEGORY]=PLAN!C$5),ROW(Table3[ITEM CODE])-8) which basically checks if the week and day matches, together with the Stock Category. If both matches, then return the row number of those rows (the result is an array).
N is defined by ROW(7:7)-MATCH("zzz",$B$1:$B7,1)+1), which is kind of a small algorithm I've used so that after each new day, I get a new N starting at 1, that increments by 1 until a new day is reached. It basically takes the current row, subtract the last row up to the current row from column B and add 1. If the two are on the same row, the result would be 1. If the current row is one row below the last row from column B, the result will be 2, etc.

VBA code required to loop through different sized rows of data and return MAX value

I am currently automating a dashboard creation and I've hit a bit of a roadblock. I need some code that will go through about 7000 rows of data and return the highest value in a certain column for each specific item. The data is copied from a pivot table and so is broken down into row sections, I have attached a mock of what it looks like.
I need the highest value in Column G for each portfolio, and will need to use the portfolio code (e.g. XY12345 - They are always 7 characters) to map that value to the dashboard.
My issue is, each portfolio has a different number of rows for the values, and some have blank cells between them, and therefore I am stumped. I was hoping to use Column J to count the number of rows for each portfolio (as there are no breaks for the portfolios in this column) and then use a loop to loop through each portfolios rows of values, based off the Column J count, and then return the highest row value for each portfolio. Problem is I'm new to VBA and have been teaching myself as I go, and I've yet to use a loop.
Many thanks,
Harry
If I understand correctly, you're looking for the largest value in Column G.
I'm not sure why you think you would need VBA for this.
Get the maximum value of a column
You mentioned that you're concerned about each column not having the same number of cells but that's irrelevant. as SUM ignores blank cells, so just "go long", or - find the maximum of the entire column.
To return the largest number in Column G you could use worksheet formula :
=MAX(G:G)
The only catch is that you can't place that formula anywhere column G or else it would create a circular cell reference (trying to infinitely add a number to itself). let's pit that formula in cell F1 for now (but anywhere besides column G would do fine).
Find the location of a value
Now that you know the largest value, you can determine where it is using a lookup function such as MATCH or VLOOKUP. Like with so many things in Excel, there are several ways to accomplish the same thing. I'll go with MATCH.
Replace the formula from above (in F1) with:
=MATCH(MAX(G:G),G:G,0)
This will return the row number of the first exact match of the maximum value of Column G.
As for the third part of question: returning the code like X12345 where the value exists, will be a little tricky since your data is not organized in a logical tabular style (tabular meaning, "like a table").
Your data is organized for humans to look at, not for machines to easily read and manipulate it. (See: Office Support: Guidelines for organizing and formatting data on a worksheet)
Basically, when organizing data in rows, all relevant information should be on the same row (not a subjective number of rows behind). Also, you have the number combined with other information.
My suggestion for a quick fix:
Right-click the heading of Column C and choose Insert to insert a blank column.
In C2 enter formula: =IF(B2="",C1,LEFT(B2,7))
Copy cell C2
Select cells in column C all the way to the "end" of your data, where ever that is (not the end of the worksheet). For example maybe you would select cells B2:B1000)
Paste the copied cell into all those cells.
Now, you can again modify the formula in F1:
=INDEX(C:C,MATCH(MAX(G:G),G:G,0))
This will return the value from Column C in the same row that the maximum value of Column G is located.
This is known as an INDEX/MATCH formula.
Hopefully this works for you in the interim until you can organize your data more logically. There's lots of related information and tutorials online.

Return last date something was entered into one column with criteria from another column

I'm working with a set of data in excel. Data is entered into rows for items specified in columns. The first column contains a date. A cell in the same row of one of the columns contains the name of a person and in another cell in the same row but different column may contain a number larger than zero (or it may be empty).
I need to create a formula which returns the date when a number larger than zero was last entered into that column for a specific name. This is a "living list" which keeps on growing and the same names appear in different rows, sometimes with a number in the column a mentioned and sometimes not.
I found an old thread on this site on a similar subject which got me as far as knowing the date of the last entry containing the persons name but I'm still not able to configure it to show me when that specific person also had a number larger than zero in that column.
Here's the thread: How to get the newest value from a column with conditions
My current formula looks like this:
=INDEX($A:$A,MATCH(MAX(IF($G:$G=Sheet7!C5,$A:$A,0)),IF($G:$G=Sheet7!C5,$A:$A,"")))
CTRL+SHIFT+ENTER
Column A contains the dates
Column G contains the names (and "Sheet7!C5" is a reference to a name)
The value column I need to add to the mix is column AY
I feel there must be a simple solution (a small add on to the formula) to solve this but I always end up with an error.
Thanks in advance :)
Edit: Here is a simplified example of the data entry and output list needed.
For this you need to sort the date DESCENDING and format the table as Excel Table
Edit: you can sort the date ascending. See explanation at the end.
Using your example, then the formula will be
=INDEX(TableData[Activity A], MATCH($B14, TableData[Employee initials], 0))
This works just like the usual VLOOKUP or INDEX MATCH, fetching the first date on an activity matching the employee initials.
You can use VLOOKUP, but you'll need to dynamically name the range of each columns.
Edit: Just today I found an interesting behavior of MATCH when it found multiple matching values. If you use 1 instead of 0, then it will fetch the last matching value on the list.
So, you can use this formula instead in ASCENDING table.
=INDEX(TableData[Activity A], MATCH($B14, TableData[Employee initials], 1))

Resources