How to duplicate a certain number of values and then change to another in Excel - excel

Hi guys I am trying to expand an existing dataset but I don't know exactly what I have to do.
For example I got this set of values in excel cloumn A:
21
45
77
I need more observations in column B, so I would like 4 observations of the same value and after excel should pass to the next original value and generate another 4 observations.
Something like this I mean:
Hope anyone can help me

If your data starts at A1 then in B1 use:
=INDEX(A:A,(SEQUENCE(COUNTA(A:A)*4)+3)/4)
(Not sure if it requires ctrl+shift+enter for versions prior to office 365)

Related

Use VLOOKUP as criteria inside COUNTIFS

After years of using this community, I have a question that I can't find an answer to. I hope you all can help!
I am trying to get a count of the number of "Grounded" items that each individual is overdue for. My screenshot (Count Tracker) shows a very condensed version of what I'm working with. Columns A-C is my large (15,000 rows) data field that is imported from an external source. In columns G-H I have listed each possible task (about 100 rows) and the type (Grounded and Non-Grounding plus many others). Column F is where I am trying to get the count.
My formula in F9 currently uses COUNTIFS to get a count of the instances in the large array that equal E9 ("Smith" in this case) and where the due date in the large array is less than or equal to the current date in F8. What I can't figure out is how to also add to count the Tasks in the large array where the task type in Column H equals "Grounded". I tried VLOOKUP, but it seems it doesn't like it and tells me there is a problem with the formula. It doesn't work, but here's the general idea of what I'm after:
=COUNTIFS($A$2:$A$7,$E9,$C$2:$C$7,"<="&$F$8,VLOOKUP($B$2:$B$7,$G$2:$H$4,2,FALSE),"=Grounded")
With how the data is currently presented, Smith should have a count of 1 and Jones should have a count of 0. I have a feeling that this is more simple than I'm making it to be, but I can't figure it out. I am using Excel 2016.
Hopefully I explained the problem well enough. Thank you for your assistance.
With Excel 2016 I'd say MMULT() is a good alternative here:
CSE-Formula in F9:
=SUM((A$2:A$7=E9)*(MMULT((TRANSPOSE(G$2:G$4)=B$2:B$7)*(TRANSPOSE(H$2:H$4)="Grounding"),ROW(G$2:G$4)^0))*(C$2:C$7<=F$8))
You could add a fourth column that stores whether that Task is Grounded
The formula for D2 would then be:
=INDEX($H$2:$H$4,MATCH(B2,$G$2:$G$4,0))
Modify your CountIfs formula to use this new column as a criteria
=COUNTIFS($A$2:$A$7,$E9,$C$2:$C$7,"<="&$F$8,$D$2:$D$7, "Grounded")
Try this Sumproduct+Vlookup formula without helper solution, and can work for your Excel 2016
In F9, formula copied down :
=SUMPRODUCT((A$2:A$7=E9)*(VLOOKUP(T(IF({1},$B$2:$B$7)),G$2:H$4,2,0)="Grounded")*($C$2:$C$7<=$F$8))

(Excel) How to return column header of the nth highest values with formula

Given a table like this one below:
David
Mike
Lisa
David
50
10
40
Mike
0
50
50
Lisa
10
40
50
I'm trying to come up with a column of formulas and information that will automatically rank and label. See below for a correct output example.
Chosen Row ->
Mike (this cell is defined by the user)
Rank
Number
Mike
50
Lisa
50
David
0
Basically the user should be able to change the top right cell and have the rest of the table automatically adjust based on that input.
Here, the user input "Mike" into the cell, so the formulas should look into the row labeled "Mike" (with the values 0, 50, and 50 in that order) and tell me a list of the highest scoring column names, along with their scores.
The only thing that is tripping me up is integrating something into the formula that makes it skip names it has already put into the rank list. As you can see, there are 2 scores of 50 there.
There is a page for this on Microsofts website on dealing with ties, but I don't fully grasp their example where they use Countif, so I have not been able to translate it over for my purposes. They also use rank numbers to the left of the names in their example, but I'd prefer that not be necessary if possible. I don't mind writing the cell formulas by hand if auto-fill doesn't help me with certain aspects.
I know there is a way to accomplish this. I've played with the formulas and did a lot of research. I've just about resorted to coding it all in VBA, but I feel like that would be far more work. At this point I'm so close, I feel like I'm just missing one critical element.
If one has the dynamic formula in Office 365 then we can use SORT:
=SORT(CHOOSE({1,2},TRANSPOSE(B1:D1),TRANSPOSE(INDEX(B2:D4,MATCH(H1,A2:A4,0),0))),2,-1)
And Excel will spill the results correctly.
For older we need two formula:
First get the values in order:
=LARGE(INDEX($B$2:$D$4,MATCH($H$1,$A$2:$A$4,0),0),ROW(ZZ1))
Put that in H2 and copy down.
Then we need to reference those value to get the correct name:
=INDEX($B$1:$D$1,AGGREGATE(15,7,(COLUMN(INDEX($B$2:$D$4,MATCH($H$1,$A$2:$A$4,0),0))-MIN(COLUMN(INDEX($B$2:$D$4,MATCH($H$1,$A$2:$A$4,0),0)))+1)/(INDEX($B$2:$D$4,MATCH($H$1,$A$2:$A$4,0),0)=H2),COUNTIF($H$2:H2,H2)))
Put that in G2 and copy down.
I made in excel 2016, but I think it works in all versions. First I created a Rank, then I used the Index function. Download the file here:
https://1drv.ms/x/s!Apn_2zN0NfqFhWT-OdNazVTlxI2n?e=WsZLuH
Code for Rank using array formula:
=MATCH(LARGE(INDIRECT("B"&$K$1&":D"&$K$1)+COLUMN(INDIRECT("B"&$K$1&":D"&$K$1))/100000,ROW()-2),
INDIRECT("B"&$K$1&":D"&$K$1)+COLUMN(INDIRECT("B"&$K$1&":D"&$K$1))/100000,0)

Deconstruct Excel Formula To Get Result Without Trying Values

I need to deconstruct Excel formulas so that I don't have to put values in to see what the result is. I want to put in a result and get a values. I know this is difficult given with multiple variables the answer could be different. I'm looking for more of a theory or method to use to so that I don't have to hunt and peck for answers.
This is my simplified sheet.
A B C Formula for column C
(Row 1) 25 10 (=IF(B1<15,5,10))
(Row 2) 15 22 (=ROUND((AVERAGE(B1:B3)),0))
(Row 3) 25 18 (=ROUND(((B3*5)/7),0))
Total 50 (=SUM(C1:C3))
For example, I want to come out with a total of 48. How would I go about working backwards so I didn't have to put a different number in column B to try and get the answer I am looking for, in this case, 48?
Have you tried Goal Seek, the disadvantage is it will only change 1 cell.
Using the Solver will change all three cells, but you then need to set constraints on the cells in column B.

How to add random number in each cell of a column?

I am sure this is a pretty naive question, but I have never done this before, so please bear with me. I have an Excel sheet with multiple columns. For one of the column, I have to add a random number in each cell of that column.
E.g.
Col1 Col2
45 12
34 34
12 12
56 78
78 30
Now In the second column, I have to add something random, say between 0 to 10. I cannot put completely random values in the second column, as all I want is a slight deviation from the already existing values.
I know how to generate random numbers, using RAND() or RANDBETWEEN(). I also know that I can convert it to integer using ROUNDUP() and then SUM() it up. But when I try to do it using formula, it gives me circular reference warning, which is correct.
Can someone help with this? Your help is very much appreciated.
You can't reference B2 within cell B2 without getting a circular reference. Unless you want to "hardcode" the value for each cell, e.g. in B2 =12+RAND(), in B3 =34+RAND()....I suggest you use a third column with this formula or similar in C2 copied down
=B2+RAND()
Something like (for the second column):
=A2-5+RANDBETWEEN(1,10)
The -5 is added if you want both smaller and larger then the number in the first column

Excel 2007, value distribution

I am working with Excel 2007, I have 10 values in names (lets 5 masonry, 3 RC, 1 Stone and 1 Wood), I want to distribute These values two 100 other cells with the same frequency. Can anybody help me with any formula?
From the information you've given us, if you had the original ten values in (say) A2:A11, it would be sufficient to use the following formula copied down to pick one of them with the same frequency:-
=INDEX(A$2:A$11,RANDBETWEEN(1,10))
As mentioned, you won't in general get exactly 50,30,10,10 values doing it this way.
You could make it a bit more general by using COUNTA to get the number of values (assuming there is a header in A1 then a list of values followed by blanks):-
=INDEX(A:A,RANDBETWEEN(2,COUNTA(A:A)))

Resources