Excel: retrieve data based on a column - excel

I have an excel document with a checklist like this one:
| number | yes/no | notes |
| 1 | yes | blablabla |
| 2 | yes | twinkle twinkle |
| 3 | no | little star |
I'd like to "echo" the fields which are set as "no" (in the second column) in another sheet, echoing the columns "number" and "notes". The result of my example would be:
| number | notes |
| 3 | little star |
How could I do it? Thanks!

Assuming your Main Table is in Sheet2, range A2:A4 (row 1 being headers). Use this formula, as an array (enter with CTRL+SHIFT+ENTER) in your sheet 2:
=INDEX(Sheet2!A$2:A$4,SMALL(IF(Sheet2!$B$2:$B$4="No",ROW(Sheet2!A$2:A$4)-ROW(Sheet2!A$2)+1),ROWS(Sheet2!A$2:A2)))
This will return all the Numbers. To get the Notes, change the very first index range to Sheet2!C$2:C$4. Obviously adjust your range down as necessary (I doubt you only have 4 of these).
Finally, just wrap an IfError() around that, so it looks nice when you use it. As you add data to your table, your table of only "no" values will update.
=IfError(INDEX(Sheet2!A$2:A$4,SMALL(IF(Sheet2!$B$2:$B$4="No",ROW(Sheet2!A$2:A$4)-ROW(Sheet2!A$2)+1),ROWS(Sheet2!A$2:A2))),"").
edit:
Screenshots:
(Using the IfError([above formula],"") wrapper hides the #NUM results when there's no match.)

Related

Find in which columns lies the text?

Thanks for reading this!
Lets say we have 2 columns in this workbook called "Data":
| Column A | Column B |
| -------- | -------------- |
| Joshua | Noah |
| Daniel | Joshua |
In another workbook, I want the user to input some random name in a cell.
Below that cell, I want to be able to show him/her, in which column that name lies. E.g. if he types "Joshua", I want to be shown below:
||
|--|
|Column A|
|Column B|
I prefer using a formula, instead of VBA, as it would mess with my not-so-experienced end-user!
Notes: See below my attempt if you find it useful:
(1) I tried that using a nested IF + FILTER functions inside, but the IF returns only the first TRUE column, like this:
| |
|------|
| Column A |
| Column A |
Here is my actual formula, where I'm referring to split ranges in sheet "6", where I have 4 columns:
IF(NOT(ISERROR(FILTER('6'!B4#,ISNUMBER(SEARCH($F$4,'6'!B4#))))),'6'!$B$1,
IF(NOT(ISERROR(FILTER('6'!D4#,ISNUMBER(SEARCH($F$4,'6'!D4#))))),'6'!$D$1,
IF(NOT(ISERROR(FILTER('6'!F4#,ISNUMBER(SEARCH($F$4,'6'!F4#))))),'6'!$F$1,
IF(NOT(ISERROR(FILTER('6'!H4#,ISNUMBER(SEARCH($F$4,'6'!H4#))))),'6'!$H$1,""))))
You could use:
Formula in D2:
=FILTER(TRANSPOSE(A1:B1),MMULT(--(TRANSPOSE(A2:B3)=D1),SEQUENCE(ROWS(A2:B3),,,0)),"")
You can get the column numbers with this formula (original data on worksheet "10")
=AGGREGATE(15,6,1/('10'!A:D="Joshua")*COLUMN('10'!A:D),SEQUENCE(COUNTIF('10'!A:D,"Joshua")))
Although I suggest reducing the range references from full columns to something shorter to reduce calculation times.
With Office 365, you can convert the column number to the letter with this:
=LET(col,AGGREGATE(15,6,1/('10'!A:D="Joshua")*COLUMN('10'!A:D),SEQUENCE(COUNTIF('10'!A:D,"Joshua"))),
adr,ADDRESS(1,col,2),
"Column " & LEFT(adr,FIND("$",adr)-1))

Sum All VLOOKUP Matches

I have a sheet where I am recording what I eat:
Another where I keep an index of values to lookup
I tried
=SUM(VLOOKUP('Sheet1'!A2:A11,'Sheet2'!A2:E11,2,FALSE))
but that only returned the first match, so then I tried
=SUMPRODUCT(SUMIF('Sheet1'!A2:A11,'Sheet2'!A2:A11,'Sheet2'!B2:B11))
but that isn't working either.
does anyone have a solution, where I can also multiply the value of the return match by the # of servings in the first sheet?
Thanks!
If you want a single output of calories through SUMPRODUCT then you can use
=SUMPRODUCT(B2:B11*IFERROR(VLOOKUP(A2:A11,Sheet2!A2:B11,2,0),0))
If you are sure that all entries on Sheet 1 can be located on Sheet 2 then you can drop IFERROR portion like
=SUMPRODUCT(B2:B11*VLOOKUP(A2:A11,Sheet2!A2:B11,2,0)).
Beware that if a value is not found in Sheet 2 then formula will produce wrong result as IFERROR will multiply the serving quantity with 0.
I combine 2 tables into one sheet, Table 1 housed in Column A & B and Table 2 housed in Column D & E
In G2, "Total Serving Colories" enter formula :
=SUMPRODUCT(VLOOKUP(T(IF({1},A2:A12)),D2:E12,2,FALSE)*B2:B12)
It's not super-clear what you're trying to get at. But defining the "Calories Per Serving" in a range called "cals",
+---+---------+-----+--------------------------------+
| | A | B | C |
+---+---------+-----+--------------------------------+
| 1 | egg | 3 | =(VLOOKUP(A2,cals,2,FALSE))*B2 |
| 2 | oatmeal | 1.5 | =(VLOOKUP(A3,cals,2,FALSE))*B3 |
| 3 | shrimp | 2 | =(VLOOKUP(A4,cals,2,FALSE))*B4 |
+---+---------+-----+--------------------------------+
Results in:

Powerpivot - Create flag if the row value of one column exists anywhere in another column

What I'm trying to accomplish doesn't seem too tricky, and should be doable I just can't seem to crack it.
All I need to do is create a calculated column that flags whether or not the row value in one column exists anywhere in another column within the same table.
id | Code 1 | Code 2 | Attempted results
--------------------------------------------------------------------------
1 | 1095829 | 1093895 | Y
2 | 1093895 | 1838949 | N
3 | 1095289 | 1093910 | Y
4 | 1093910 | 1840193 | N
So essentially, is Code 1 found anywhere in the code 2 column
You should be able to do this using an IF/MATCH formula. For example:
=IF(MATCH(B2,C:C,0),"Duplicate", "Unique")
This would check if B2 (1095829) shows up anywhere in the C column. If it does, it returns "Duplicate" to that cell, if it does not, then it returns "Unique".

Count number of rows where multiple criteria are met

I'm trying to generate a table that shows a count of how many items are in any given status on any given day. My result table has a set of Dates down column A and column headers are various statuses. A sample of my data table with headers looks like this:
Product | Notice | Assigned | Complete | In Office | In Accounting
1 | 5/5/13 | 5/7/13 | 5/9/13 | 5/10/13 | 5/11/13
2 | 5/5/13 | 5/6/13 | 5/8/13 | 5/9/13 | 5/10/13
3 | 5/6/13 | 5/9/13 | 5/10/13 | 5/10/13 | 5/10/13
4 | 5/4/13 | 5/5/13 | 5/7/13 | 5/8/13 | 5/9/13
5 | 5/7/13 | 5/8/13 | 5/10/13 | 5/11/13 | 5/11/13
If my output table were to contain a set of dates in the first column with the statuses as headers, I need a count of how many rows were at the given status and had not yet transitioned to the next status so that in the Notice column, I'd have a count of rows where the Notice Date was <= X AND where the Assigned, Complete, In Office, In Accounting are all greater than X.
I've used a Sum(if(frequency(if statement to get me REALLY close but I feel like I need to have an AND statement within the second IF like this =SUM(IF(FREQUENCY(IF(AND
Here's what I have that won't work:
=SUM(IF(FREQUENCY(IF(AND(Table1[Assigned]<=A279,Table1[[Complete]:[In Accounting]]<=A279),ROW(Table1[[Complete]:[In Accounting]])),ROW(Table1[[Complete]:[In Accounting]]))>0,1))
If I take the "AND" portion out, this works fine except I need it to ONLY count rows where the given status actually has a date so if an "Assigned" date is empty, I don't want that row to be counted for the Assigned column.
Here's an example of what I'd expect to see in the results. I've listed the count in the each column as well as the corresponding product numbers in parenthesis. The corresponding product numbers are for reference only and won't actually be in the result table.
Date | Notice | Assigned | Complete
5/6 | 2 (1,3) | 2 (2,4) | 0
5/7 | 2 (3,5) | 2 (1,2) | 1 (4)
5/8 | 1 (3) | 2 (1,5) | 1 (2)
OK, assuming you have the original data in A1:F6 then with 2nd table headers in B9:D9 and row labels in A10:A12 then you can use this "array formula" in B10
=SUM((B$2:B$6<=$A10)*(MMULT((C$2:$F$6>$A10)+(C$2:$F$6=""),TRANSPOSE(COLUMN(C$2:$F$6)^0))=COLUMNS(C$2:$F$6)))
confirmed with CTRL+SHIFT+ENTER and copied down and across (see screenshot below)
As you can see the results are as per your requirement. If you replace dates with blanks it will still work
MMULTis a way to get a single value from each row even when you are looking at multiple columns.
I used cell references because I think that's easier, especially when copying the formula across and having a reducing range.......but you can use structured references if you want
Have you tried using COUNTIFS to count based on multiple criteria. It is fairly well documented here: http://office.microsoft.com/en-us/excel-help/countifs-function-HA010047494.aspx (2007+ only)
Basically, you use it like
=COUNTIFS(first_range_to_check, value_you_want_in_first_range, ...)
where the ... represents as many pairs as you want (up to 127 total pairs), note the conditions are AND connection so if you have two pairs, the first pair AND the second pair must return true for that row to count.

Isolate Rows that Contain Certain Values in One Column (Excel)

I need help with what I think is a simple Excel formula or function. I have two columns. As an easy example let's say the first column is numbers and the second column is colors:
| 1 | Red |
| 2 | Blue |
| 3 | Red |
| 4 | Red |
| 5 | Green|
| 6 | Brown|
Let's say I just wanted the rows with red in the second column and have everything else on the sheet deleted. How would I do that? To be clear, I want the values in column one to remain as well. This is how I would like it to look:
| 1 | Red |
| 3 | Red |
| 4 | Red |
It seems like it should be simple but I can't seem to find any way to do that. There are similar question on the forum but they are more complex than what I'm asking and require super long formulas. If that's what is required, I suppose that's what I'll do but just wanted to see if there was an easy way to do it as well. Thanks for the help!
You can use autofilter to filter the second column. Then select and copy the visible cells only, remove the filter, delete everything and paste what's in the clipboard.
Or do you need a dynamic solution? Then you could build a pivot table on a separate sheet. Put the desired color in the page filter and refresh the pivot table when the source data has changed.

Resources