How do I get each column of the same row in one line? - excel

I have this columns in excel:
A B C D E F
Nima1 1 2 3 4 5
Nima2 6 7 8 9 10
Nima3 11 12 13 14 15
Nima4 16 17 18 19 20
and I want to show them like this:
Nima1 1
Nima1 2
Nima1 3
Nima1 4
Nima1 5
Nima2 6
…
Nima4 20
and so far I come up with nothing, every formula that I write doesn't work.
please if anyone knows how to do it, guide me through it.

In any unused cell to the right put in this formula,
'for system that use a comma as a list separator
=INDEX(A:E,(ROW(1:1)-1)/5+1,IF(COLUMN(A:A)=1,1,MOD(ROW(1:1)-1,5)+1))
'for system that use a semi-colon as a list separator
=INDEX(A:E;(ROW(1:1)-1)/5+1;IF(COLUMN(A:A)=1;1;MOD(ROW(1:1)-1;5)+1))
Fill right one column then fill both down until you get zeroes.

Related

Excel MERGE two tables

I have SET 1
CLASS
Student
TEST
SCORE
A
1
1
46
A
1
2
50
A
1
3
45
A
2
1
45
A
2
2
47
A
2
3
31
A
3
1
34
A
3
2
45
B
1
1
36
B
2
1
31
B
2
2
41
B
3
1
50
C
1
1
42
C
3
1
31
and SET 2
CLASS
SIZE
YEARS
A
39
7
B
20
12
C
31
6
and wish to COMBINE to make SET 3
CLASS
STUDENT
TEST
SCORE
SIZE
YEARS
A
1
1
46
39
7
A
1
2
50
39
7
A
1
3
45
39
7
A
2
1
45
39
7
A
2
2
47
39
7
A
2
3
31
39
7
A
3
1
34
39
7
A
3
2
45
39
7
B
1
1
36
20
12
B
2
1
31
20
12
B
2
2
41
20
12
B
3
1
50
20
12
C
1
1
42
31
6
C
3
1
31
31
6
so basically add the SIZE and YEARS columns from SET 2 and merge on CLASS onto SET 1. In excel how you can do this? I need to match on CLASS
Define both sets as tables and “left join” in PowerQuery. There you can choose the columns of the resulting table.
https://learn.microsoft.com/en-us/power-query/merge-queries-left-outer
If you have Set 1 on the top left of a worksheet "Set1" and Set 2 on the top left of a worksheet "Set2", then you can use the formula
=VLOOKUP(A2;'Set2'!$A$2:$C$4;2;FALSE), where $A$2:$C$4 is the range of Set2, and A2 is the class value from Set1, which is what is used to do the lookup in Set2. The next argument, 2, means to take the second row from Set2, and the FALSE at the end means that you only want exact matches on the CLASS. You can do auto-fill with this formula, and do similar steps for the years. If you look up the help for VLOOKUP within Excel, that should help you to understand how it works.
Your first set of data is essentially your primary set of data that you just want to add attribute columns to. I built this example on Google Sheets which should help explain. Using spill formulas, only a few cells are needed with their own formulas. You can see them as they are highlighted in yellow. When you use in Excel, obviously make sure you change the column references, but this would get you the answer.
Note you have to have SpillRange in Excel for this to work. To test, see if you have the formula =unique()
This solution may work for you if both sets start in the same column. As example in my image, both of them start at column A. You can get all data with a single VLOOKUP formula:
Formula in cell E2 is:
=VLOOKUP($A2;$A$22:$R$25;COLUMN($B22);FALSE)
Notice the mixed references at first and third argument and absolute references in the second one. Third argument is critical, because is the relational position between both sets, that's the reason it's easier if both sets start at same column. If not, you'll need to adjust this argument substracting or adding, depending on the case.
Anyways, with a single formula, you can get any number of columns. The only disavantage of this formula is that you need to manually drag to right until you got all the columns (10, 30 or whatever). You'll notice you are done because the formula will raise an error:
This error means you are trying to get a referenced outside of your column area.

Counting total number in Excel with a specific value in cells and a single column

Hope someone can help me out with what is probably quite a simple thing in Excel but I just can't seem to be able to work it out. I have a table of numbers which correspond to colour codes:
A
B
C
D
E
F
2
2
2
2
2
24
36
36
2
2
2
24
2
2
2
2
2
2
36
2
36
2
2
24
2
2
36
2
2
2
2
36
2
2
2
24
2
2
2
2
36
2
What I would like to able to have is some way of having a total based on the criteria:
Count the total number of times '36' appears in the table only if the row has '24' in column F
I've tried using COUNTIF and COUNTIFS but that only works for matching sized columns of data.
Any help would be really appreciated.
Use SUMPRODUCT:
=SUMPRODUCT((A1:E7=36)*(F1:F7=24))

Using IF and AND function

I am trying to use the IF and AND function in excel for values in two different cells. I have 25 conditions.
Below is the formula I've created but it keeps on saying there's an error.
IF(AND(A10=“A”,B10=1),11,IF(AND(A=“A”,B10=2),16,IF(AND(A10=“A”,B10=3),20,IF(AND(A10=“A”,B10=4),23,IF(AND(A10=“A”,B10=5),25,IF(AND(A10=“B”,B10=1),7,IF(AND(A10=“B”,B10=2),12,IF(AND(A10=“B”,B10=3),17,IF(AND(A10=“B”,B10=4),21,IF(AND(A10=“B”,B10=5),24,IF(AND(A10=“C”,B10=1),4,IF(AND(A10=“C”,B10=2),8,IF(AND(A10=“C”,B10=3),13,IF(AND(A10=“C”,B10=4),18,IF(AND(A10=“C”,B10=5),22,IF(AND(A10=“D”,B10=1),2,IF(AND(A10=“D”,B10=2),5,IF(AND(A10=“D”,B10=3),9,IF(AND(A10=“D”,B10=4),14,IF(AND(A10=“D”,B10=5),19,IF(AND(A10=“E”,B10=1),1,IF(AND(A10=“E”,B10=2),3,IF(AND(A10=“E”,B10=3),6,IF(AND(A10=“E”,B10=4),10,15))))))))))))))))))))))))))))))))))))))))))))))))
I expected the output to be, for example; if cell1 is "A" and cell2 is 1 the result should be 11.
I would highly advise a lookup table. Simply have all of your options listed out with their desired results and find them with a criteria search, such as the use of sumifs function.
For example, if you paste J1:L25 your possibilities:
A 1 11
A 2 16
A 3 20
A 4 23
A 5 25
B 1 7
B 2 12
B 3 17
B 4 21
B 5 24
C 1 4
C 2 8
C 3 13
C 4 18
C 5 22
D 1 2
D 2 5
D 3 9
D 4 14
D 5 19
E 1 1
E 2 3
E 3 6
E 4 10
E 5 15
You can then place the formula =SUMIFS($L$1:$L$25,$J$1:$J$25,$A$10,$K$1:$K$25,$B$10) to return your desired value.
That is, =SUMIFS(range_of_results, criteria_range_of_A-E, A10, criteria_range_of_1-5, B10)

Formula to add text based on values of two other cells

I have a large spreadsheet that needs a bit of fine-tuning. Column A contains numbers from 1-4000, sequentially-listed. Column B contains some of those same numbers, but many numbers are skipped (for example: 1, 5, 6, 7, 11, 12, 25...); those numbers are not "spaced out" relative to the numbers in column A. Column C contains text entries related to the Column B values. I need to add a formula in column D that will evaluate whether the number in A1 (for example) matches the number in B1, and if it does match it should place the value of C1 in D1. Likewise, if A2 matches B2, then the value of C2 should be placed in D1.
I tried writing some formulas similar to this, but they become far too large when you have to take into account every cell combination: =IF(A1=E1,F1). If I can just get the column B cells to "space themselves out" so that they match up with the cells in column A, that would get me where I need to be. Of course, the Column C data values would need to "follow along" with the Column B values when they are spaced out.
Any ideas on how I can make this happen?
If the data is like this:
A B C
---------------
1 1 Red
2 5 Blue
3 6 Red
4 7 Yellow
5 11 Black
6 12 Green
7 25 Yellow
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
And the desired result is this:
A B C D
--------------------
1 1 Red Red
2 5 Blue
3 6 Red
4 7 Yellow
5 11 Black Blue
6 12 Green Red
7 25 Yellow Yellow
8
9
10
11 Black
12 Green
13
14
15
16
17
18
19
20
21
22
23
24
25 Yellow
We can accomplish that using an INDEX-MATCH based formula starting in D1 and auto filling down:
=IFERROR(INDEX(C:C,MATCH(A1,B:B,0)),"")
It will look like this:
A B C D
-----------------------------------------------------------
1 1 Red =IFERROR(INDEX(C:C,MATCH(A1,B:B,0)),"")
2 5 Blue =IFERROR(INDEX(C:C,MATCH(A2,B:B,0)),"")
3 6 Red =IFERROR(INDEX(C:C,MATCH(A3,B:B,0)),"")
4 7 Yellow =IFERROR(INDEX(C:C,MATCH(A4,B:B,0)),"")
5 11 Black =IFERROR(INDEX(C:C,MATCH(A5,B:B,0)),"")
6 12 Green =IFERROR(INDEX(C:C,MATCH(A6,B:B,0)),"")
7 25 Yellow =IFERROR(INDEX(C:C,MATCH(A7,B:B,0)),"")
8 =IFERROR(INDEX(C:C,MATCH(A8,B:B,0)),"")
9 =IFERROR(INDEX(C:C,MATCH(A9,B:B,0)),"")
10 =IFERROR(INDEX(C:C,MATCH(A10,B:B,0)),"")
11 =IFERROR(INDEX(C:C,MATCH(A11,B:B,0)),"")
12 =IFERROR(INDEX(C:C,MATCH(A12,B:B,0)),"")
13 =IFERROR(INDEX(C:C,MATCH(A13,B:B,0)),"")
14 =IFERROR(INDEX(C:C,MATCH(A14,B:B,0)),"")
15 =IFERROR(INDEX(C:C,MATCH(A15,B:B,0)),"")
16 =IFERROR(INDEX(C:C,MATCH(A16,B:B,0)),"")
17 =IFERROR(INDEX(C:C,MATCH(A17,B:B,0)),"")
18 =IFERROR(INDEX(C:C,MATCH(A18,B:B,0)),"")
19 =IFERROR(INDEX(C:C,MATCH(A19,B:B,0)),"")
20 =IFERROR(INDEX(C:C,MATCH(A20,B:B,0)),"")
21 =IFERROR(INDEX(C:C,MATCH(A21,B:B,0)),"")
22 =IFERROR(INDEX(C:C,MATCH(A22,B:B,0)),"")
23 =IFERROR(INDEX(C:C,MATCH(A23,B:B,0)),"")
24 =IFERROR(INDEX(C:C,MATCH(A24,B:B,0)),"")
25 =IFERROR(INDEX(C:C,MATCH(A25,B:B,0)),"")

Sum number according to date and name in excel

To sum the third column (numbers o companies) I've used this
=SUM(1/COUNTIF(Names;Names))
Names is name of array in C column and CTRL+SHIFT+ENTER and it works perfectly.
Now I'd like to sum earnings but only for each company once and with the latest data. For example, the result shoud be like this
=C4+C6+C7+C8+C9+C10
(93)
Thanks
A B C D
1 # company earnings date
2 1 ISB 12 10/11/2011
3 2 DTN 15 11/11/2011
4 3 ABC 13 12/11/2011
5 4 ISB 17 13/11/2011
6 5 RTV 18 14/11/2011
7 6 DTN 22 15/11/2011
8 7 PVS 11 16/11/2011
9 8 ISB 19 17/11/2011
10 9 ANH 10 18/11/2011
Sum 6 93
Assuming ascending dates, you could try with CTRL+SHIFT+ENTER in C11:
=SUM((MAX(A2:A10)-MATCH(B2:B10,LOOKUP(MAX(A2:A10)-A2:A10,A2:A10-1,B2:B10),0)=A2:A10-1)*C2:C10)
I'd suggest using a helper column as the easiest approach. In E2 use this formula
=IF(COUNTIF(B2:B$1000,B2)=1,C2,"")
and copy down the column. Now sum column D for the required answer.
Note that the above formula assumes 1000 rows of data maximum, increase if required.

Resources