How to Transpose the data in Pivot table? - excel

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.

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))))

how to sample from a data frame along with the original indexing?

I have a pandas dataframe and would like to use .sample(frac=0.1) and create a subset of the dataset. However, I would like to have the original indexing maintained in the subset. Is this possible?
If need original index values just use your solution:
df = pd.DataFrame({'a':range(10, 100)})
print (df.sample(frac=0.1))
a
60 70
64 74
70 80
63 73
40 50
57 67
77 87
30 40
66 76
If need default index values add DataFrame.reset_index with drop=True:
print (df.sample(frac=0.1).reset_index(drop=True))
a
0 87
1 92
2 47
3 81
4 68
5 75
6 14
7 80
8 34

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.

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

Merge cells if another cell has the same value

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

Resources