Excel to return list of items with specific repetition - excel

I am trying to create a list of names that repeat a specific number of times, based on another variable. Basically, if I have the following:
Column A Column B
Amy 5
John 2
Carl 3
the result would be:
Amy
Amy
Amy
Amy
Amy
Carl
Carl
Carl
John
John
I have built the initial list using the Index-Small-Countif, method, to get an alphabetical and distinct list, and then another formula to determine how many times each item repeats. I know I need to use some sort of index/offset with reference to rows, but just can't quite get it to work out.
The list is dynamic and changes daily, so manually retyping the list each day would result in too much human error and time (list is about 50 distinct items, with total number of rows at the end being around 400). Ultimately, the list will be used for a number of sumproduct/vlookups.
I can do this fairly quickly in VBA, but the users of this document don't always trust VBA and trying to get them to Enable Macros each time is not something that is going to work.
Thank you very much for any help you can offer!

Based on your table:
+---+------+---+
| | A | B |
+---+------+---+
| 1 | Amy | 5 |
| 2 | John | 2 |
| 3 | Carl | 3 |
+---+------+---+
In column C stick a "0" at C4 and formula =B1+C2 copying down to just before the 0:
+---+------+---+----+
| | A | B | C |
+---+------+---+----+
| 1 | Amy | 5 | 10 |
| 2 | John | 2 | 5 |
| 3 | Carl | 3 | 3 |
| 4 | | | 0 |
+---+------+---+----+
Now we have an upper bound of the row that each value should be placed on which we can use in a Match() formula which will feed an Index() formula.
In a new column (I'm using E) IN E1: =INDEX($A$1:$A$3,MATCH(ROW(),$C$1:$C$3,-1),1) and copy down
+----+------+---+----+--+------+
| | A | B | C | D | E |
+----+------+---+----+--+------+
| 1 | Amy | 5 | 10 | | Carl |
| 2 | John | 2 | 5 | | Carl |
| 3 | Carl | 3 | 3 | | Carl |
| 4 | | | 0 | | John |
| 5 | | | | | John |
| 6 | | | | | Amy |
| 7 | | | | | Amy |
| 8 | | | | | Amy |
| 9 | | | | | Amy |
| 10 | | | | | Amy |
+----+------+---+----+--+------+
The list is backwards because of that oddball backwards from 0 thing we did in Column C. This is to make that Match() last parameter of -1 (Greater than) work correctly.
I would imagine with some tweaking this could be done a little cleaner, but this should get you in the ballpark.
Although I would still be a big proponent of finding users who are capable of enabling macros. Ugh.

Related

Excel In cell formula Number of surveys administered

Good Afternoon,
I have an excel sheet that records encounters with community residents by name and date. During each encounter a brief survey is also administered. I want to track changes to these survey questions by name over time. Is there any way to do this with in cell formulas? Here's an example of the table I have in mind:
| Name | Date | Q1 | Q2 | Stress | Survey Number |
| | | | | | (calculated) |
|--------------|------------------|----|----|--------|---------------|
| Steve Rogers | 5/1/2018 | y | y | 5 | 1 |
| Steve Rogers | 5/2/2018 | y | y | 6 | 2 |
| Tony Stark | 5/1/2018 | n | n | 10 | 1 |
| Nick Fury | 5/1/2018 | n | y | 8 | 1 |
| Nick Fury | 5/2/2018 | y | y | 5 | 2 |
| Tony Stark | 5/2/2018 | y | n | 8 | 2 |
| Tony Stark | 5/3/2018 | n | n | 4 | 3 |
I want to calculate the survey number by referencing the name and the date. I have no idea where to start, honestly. Is this even possible using an in-cell reference?
Use COUNTIFS()
=COUNTIFS(A:A,A2,B:B,"<=" & B2)
Put that in F2 and copy/drag down.

excel: filter using formulas

I have a list of people who belong to two groups (A or B). I want to create a column which lists all the people who belong to group A.
I have been trying to come up with an array formula but I do not have a working example. Any help appreciated!
Names | Group | Desired Output
Bob | A | Bob
Fred | B | Eric
Matt | B | Dave
Eric | A | Fred
Dave | A |
Stew | B |
Fred | A |
Many Thanks in advance
Normal formula for column C:
C2=
=IFERROR(INDEX(A:A,AGGREGATE(15,6,ROW(B:B)/(B:B="A"),ROW()-1)), "")
Copy/paste down in column C for a sufficient number of cells.
Array formula: select a sufficient number of cells in column C and write the same formula in the formula bar then press Ctrl+Shift+Enter
From this
+---+-------+-------+
| | A | B |
+---+-------+-------+
| 1 | Name | Group |
| 2 | Nick | A |
| 3 | Marc | A |
| 4 | Manny | B |
| 5 | Luck | A |
+---+-------+-------+
you can create two pivot tables with Name in the row label and Group in the filter data.
Then you can filter only people depending on the group.
+---+-------------------+---+
| | A | B |
+---+-------------------+---+
| 1 | Group | A |
| 2 | | |
| 3 | Etichette di riga | |
| 4 | Luck | |
| 5 | Marc | |
| 6 | Nick | |
+---+-------------------+---+
So if your data is in range A1:B7 this would be the formula:
=IFERROR(INDEX($A$1:$A$7,SMALL(IF($B$1:$B$7="A",ROW($A$1:$A$7)-ROW($A$1)+1),ROWS($A$1:A1))),"")
This is array formula that is applied with Ctrl + Shift + Enter and you will need to drag it down.

INDEX MATCH - List with excel formula based on multiple criteria

I need some help listing the opperations that meet a couple of criterias.
My dataset is pretty much like the following example:
A B C D
-----------------------------------------
1 | Opp_num | Seller_1 | Seller_2 | Aux |
-----------------------------------------
2 | 7001 | John | Tom | 1 |
3 | 7002 | Carl | John | 0 |
4 | 7003 | Mary | John | 1 |
5 | 7004 | Tom | Mary | 0 |
6 | 7005 | John | Tom | 0 |
7 | 7006 | John | Mary | 1 |
-----------------------------------------
What I really need is to list all the operations where "John" appears either in column "seller_1" or "seller_2", and also column "Aux" is equal to 1.
In this example the listed operations should be:
7001
7003
7006
I have tried a couple of things with no success.
Thanks in advance for your help!
MD
=IF(AND(D2=1,OR(C2="John",B2="John")),A2,"")
Here it is. Paste it in the cell.

Sum and recurrence for columns

i have 3 columns: A has names, B has numbers, C has names. I want to see how many times MIKE and JANE appears in the table and how many times they met. The order of the columns is not fixed so i can modify the order of the columns (the names to be in columns A and B and the numbers in C) . Any help is welcomed.
-------------------------------------------------------------
| A | B | C | D | E | F | G | H |
-------------------------------------------------------------
| TRAINER|HOURS| CHILD | |TRAINER| CHILD |HOURS|MEETINGS|
-------------------------------------------------------------
| MIKE | 2 | JANE | | MIKE | JANE | 10 | 2 |
-------------------------------------------------------------
| MIKE | 5 | STEVE | | MIKE | STEVE | 7 | 2 |
-------------------------------------------------------------
| HARRY | 3 | JANE | | HARRY | JANE | 3 | 1 |
-------------------------------------------------------------
| MIKE | 8 | JANE | | HARRY | STEVE | 7 | 1 |
-------------------------------------------------------------
| MIKE | 2 | STEVE | | | | | |
-------------------------------------------------------------
| HARRY | 7 | STEVE | | | | | |
-------------------------------------------------------------
I am going to suggest a SUMPRODUCT option. As other have mentioned there is also the SUMIF option.
=SUMPRODUCT(($A$2:$A$7=$E2)*($C$2:$C$7=$F2)*$B$2:$B$7)
If you move your C column to B update the ranges in the formula accordingly.
Now the better option as other have suggested is:
=SUMIFS($B$2:$B$7,$A$2:$A$7,$E2,$C$2:$C$7,$F2)
And I totally missed that you were looking for the number of meetings as opposed to the hours. We can again use SUMPRODUCT with one less term or we can use COUNTIFS.
=SUMPRODUCT(($A$2:$A$7=$E2)*($C$2:$C$7=$F2))
and the COUNTIFS method is
=SUMIFS($A$2:$A$7,$E2,$C$2:$C$7,$F2)

Transform values without VBA but with Index and Match

I'm trying to find a solution without macros in excel for following problem:
There is a table containing ratings of a student for different time periods.
So the rating of the student with ID=1 was 1 from January to April and 3 from Mai to June.
Two other students had a constant ranking (6 and 9) from January to June
| A | B | C |D |
---| ----|------------|------------|-------|
1 | ID | START | END |RANKING|
2 | 1 | 01.01.2014 | 30.04.2014 | 1 |
3 | 1 | 01.05.2014 | 30.06.2014 | 3 |
4 | 2 | 01.01.2014 | 30.06.2014 | 6 |
5 | 3 | 01.01.2014 | 30.06.2014 | 9 |
Next table contains IDs (y axis) and Months (x axis)
| F | G | H | I | J | K | L |
---| ----|--------|--------|--------|--------|--------|--------|
1 | ID | 201401 | 201402 | 201403 | 201404 | 201405 | 201406 |
2 | 1 | | | | | | |
3 | 2 | | | | | | |
4 | 3 | | | | | | |
And I wish to feel this second table like this:
| ID | 201401 | 201402 | 201403 | 201404 | 201405 | 201406 |
| ----|--------|--------|--------|--------|--------|--------|
| 1 | 1 | 1 | 1 | 1 | 3 | 3 |
| 2 | 6 | 6 | 6 | 6 | 6 | 6 |
| 3 | 9 | 9 | 9 | 9 | 9 | 9 |
I tried to use Index and Match, but without any good results because I haven't found a posibility to use IF (if (
Could anybody help?
You can get what you're looking for with SUMPRODUCT
Given the layout you provided, this formula should work when put in G2 and filled down and over
=SUMPRODUCT(--($A:$A=$F2),--($B:$B<=G$1),--($C:$C>G$1),$D:$D)
That looks in column A for an ID matching F2, then for every one it finds of those:
It checks the date in column B against the date in G1
It checks the date in column C against the date in G1
If all criteria match, it returns the value in Column D
This assumes you only have one entry for each period, otherwise it will sum them.
Also, you can use SUMIFS, it's a little less easy to read but I think it's slightly more efficient than SUMPRODUCT (I'm not positive, just anecdotal evidence from usage)
=SUMIFS($D:$D,$A:$A,"="&$F3,$B:$B,"<="&G$1,$C:$C,">"&G$1)
It does the exact same thing, just with different syntax.

Resources