Merge cells if another cell has the same value - excel

I have data in Excel like so:
Column1 Column2 Column3 Total
37 45 61
37 68 99
123 76 12
...
I want to produce the following:
Column1 Column2 Column3 Total
37 45 61 45, 68
37 68 99
123 76 12 76,...
...
If column1 of row1 has the same value with another row's column1 then put its column2 value in total with a comma.

Assuming 100 rows in total, please try:
=IF(ISERROR(MATCH(A2,A3:A$100,0)),"",B2&", "&VLOOKUP(A2,A3:B$100,2,0))

Assuming you have your column 1 sorted, guess this should work:
Cell D2 =IF(A2=A1,IF(D1="",C1&", "&C2,D1&", "&C2),"")
This is my test case... It gives the required total in the last repeated no. Hope its ok
C1 C2 C3 Tot
37 45 61
37 68 99 61,99
123 76 12
123 24 34 12,34
123 35 66 12,34,66
144 62 35

Related

In Excel How can I sum (or perform any operation) total sum values of various columns when the column name is mentioned in a cell?

So I have a set of Data having 6 columns under different headers.
In sheet 2 we select some variables from Data sheet (to perform sum operation in this case).
Whenever the user inputs some or all variables (Fruits, Veggies, Drinks, Snacks, Vegan, Dairy)from Data (sheet1) in to sheet 2 for items_chosen under Formula column (e.g Veggies + Drinks + Vegan) , then the output column(sheet 2) should display sum total of these selected columns, under Results.
example: We chose, (Veggies + Snacks + Dairy) ;
Now total of each of these columns are 1222(veggies) , 1927(snacks) , 328(dairy) ;
So in sheet 2 under result ,it should display = 3447 which is the sum total of [1222(veggies) + 1927(snacks) + 328(dairy)]
I know we can use Indirect function in excel but how can I take input from what is written in Choose Variables here column in sheet 2
Sample Data:
Fruits
Veggies
Drinks
Snacks
Vegan
Dairy
1
3
9
7
8
4
23
31
26
34
71
45
45
51
93
72
353
41
67
134
56
81
431
155
89
42
242
457
513
19
111
61
574
541
54
15
133
46
426
156
135
17
155
522
264
166
351
18
177
332
624
413
54
14
Output:
Label
Choose Variables here
Output
Result
Items_chosen
Veggies + Snacks + Dairy
Result of Items_chosen
Try below formula.
=SUMPRODUCT((A2:F10)*(ISNUMBER(SEARCH(A1:F1,I3))))

Excel graphic with 2 x-as variables en 2 y-as variables

How can I get a chart in Excel with:
x-as is equal to the combination of JM and location
y-as are the %-values from Occupied next or on top of empty
So in month 201801 I can see the 2 (or more max 30) locations with both %-values
next to month 201802 and so on.
(Eventualy I can set a trendline on Occupied)
Hopefully my question is clear
The is a short example table:
JM location Occupied% Empty%
201801 A 80 20
201801 B 54 46
201802 A 64 36
201802 B 89 11
201803 A 50 50
201803 B 89 11
201804 A 99 1
201804 B 67 33
201805 A 100 0
201805 B 78 22
201806 A 98 2
201806 B 86 14
201807 A 93 7
201807 B 58 42
201808 A 67 33
201808 B 79 21
201809 A 67 33
201809 B 57 43
201810 A 98 2
201810 B 97 3
201811 A 65 35
201811 B 68 32
201812 A 87 13
201812 B 99 1
Very easy with a pivottable. Select Insert, Pivottable and drag JM to the row field area and Location to the column field area and Occupied to the sigma area. Then insert a line pivot chart.

Excel - calculate average of values in one column based on another grouping column. The number of rows is not constant per group

Two columns, one with ID and one with values. I want to calculate average per ID. The number of rows per ID is not constant. What i have:
ID Value
1 22
1 31
1 34
1 23
1 31
34 67
34 65
34 55
12 44
12 46
12 43
12 35
I want a formula which will calculate third column:
ID Value Average per id
1 22 28.2
1 31 28.2
1 34 28.2
1 23 28.2
1 31 28.2
34 67 62.3
34 65 62.3
34 55 62.3
12 44 42.0
12 46 42.0
12 43 42.0
12 35 42.0
I have tried AVERAGEIF function but i cant figure it out.
Just use these formulas:
=AVERAGEIF(A:A,A2,B:B)
or
=SUMIF(A:A,A2,B:B)/COUNTIF(A:A,A2)

Finding the median of a range of values selected using vlookup

Column A are dates and B & C are Measurements
Dates Measurements
1 56 15
2 45 25
3 62 76
4 15 42
5 165 56
6 16 79
7 45 46
8 47 79
9 24 47
10 12 14
11 147 47
12 195 19
13 443 79
14 642 43
15 462 75
16 156 87
17 794 49
Start Date:2
Measurement:45
Code used to solve for the measurement
=VLOOKUP(B21,A2:C18,2,FALSE)
end date:14
Measure:642
=VLOOKUP(B22,A2:C18,2,FALSE)
I used vlookup to find me the values that I desire, but now I want to find the median values of that range from the start to end date in each column.
How can I code it so that once it selects the values, it can select the whole range and find the median values?
Since your column A values are ordered ascendingly, we can use the very efficient:
=MEDIAN(INDEX(B2:B18,MATCH(B21,A2:A18)):INDEX(B2:B18,MATCH(B22,A2:A18,0)))
Regards

How to Transpose the data in Pivot table?

I have a source content as shown below
Name Age Month Maths Science Physics
John 21 1 80 88 76
John 21 2 89 99 78
John 21 3 76 76 89
John 21 4 78 78 90
John 21 5 88 89 96
Sara 22 1 76 76 89
Sara 22 2 78 78 90
Sara 22 3 88 89 96
Sara 22 4 76 76 89
Sara 22 5 78 78 90
and i am looking to create a pivot table in excel something like this.
Name John
Age All
Month 1 2 3 4 5
Maths 80 89 76 78 88
Science 88 99 76 78 89
Physics 76 78 89 90 96
Is this possible? Thanks for looking
On your destination sheet, select an empty range with the correct number of columns and rows.
On the Formulas ribbon, select Insert Function and then specify All Functions in the dialog box.
In the list of functions, select Transpose, and give the entire range from the source sheet that you wish to transpose;
Click OK - your data range should now be transposed on the destination sheet
Select the entire destination range and then on the Data Ribbon select Auto-Filter.
You can now filter on any of the columns as desired.
In the above answer, at step 3, you need to make the TRANSPOSE function an array formula. In other words, hit "C-S-E" -- Control-Shift-Enter. Then your function is surrounded by curly brackets indicating it is an array function.

Resources