How to transpose multiple columns to multiple rows excel? - excel

Current data set:
14 72 73
54 75 66
98 87 65
Desired outcome:
14 72 73 54 75 66 98 87 65
I want to transpose multiple columns to multiple rows, any one have =OFFSET formula to make this done..

If 14 is in A2 then in say E2 and copied down something like:
=E1&","&A2&","&B2&","&C2
will concatenate the values in a single cell (with comma as the delimiter). To split these out, copy ColumnE, Paste Special, Values over the top and then apply Text to Columns to it, with comma as the delimiter.

Related

How to add new calculations to existing table based on text field with multiple entries?

Question: How can I populate the [score [TXT]] columns with the specified calculation? Sometimes the calculations will be based off multiple rows depending on the value in the [game] column.
I have a table with Metascores and game names, and want to apply some sort of formula that automatically calculates the AVG, MAX, and MIN for the entry. The table above has my desired output. I am using Office 365 - Excel.
Current table
Metascore
score AVG
score MAX
score MIN
game
87
Assassin's Creed Odyssey
86
Assassin's Creed Odyssey
83
Assassin's Creed Odyssey
66
Bleeding Edge
62
Bleeding Edge
Desired output
Metascore
score AVG
score MAX
score MIN
game
87
85.3
87
83
Assassin's Creed Odyssey
86
85.3
87
83
Assassin's Creed Odyssey
83
85.3
87
83
Assassin's Creed Odyssey
66
64
66
62
Bleeding Edge
62
64
66
62
Bleeding Edge
Some titles only occur once, some several times. Is there a formula or script I can apply that loops through the table and applied the calculation, or a different suggestion of an output?
Thanks for your help!!
=UNIQUE(E2:E6) in for instance E10
=AVERAGEIF($E$2:$E$6,$E$10#,A2:A6) in A10 and copy to the right.
Or in one go using LET:
=LET(data,A2:E6,
game,INDEX(data,,5),
unique,UNIQUE(game),
CHOOSE({1,2,3,4,5},
AVERAGEIF(game, unique,INDEX(data,,1)),
AVERAGEIF(game, unique,INDEX(data,,2)),
AVERAGEIF(game, unique,INDEX(data,,3)),
AVERAGEIF(game, unique,INDEX(data,,4)),
unique))
Edit:
After the changed description, this is what you need:
In B2 use: =AVERAGEIF(E2:E6,E2:E6,A2:A6)
In C2 use: =MAXIFS(A2:A6,E2:E6,E2:E6)
In D2 use: =MINIFS(A2:A6,E2:E6,E2:E6)
If you'd have your data in two columns (let's say A20:B20) and would want a summary elsewhere, you could use the following:
=LET(data,A2:B6,
game,INDEX(data,,2),
score,INDEX(data,,1),
unique,UNIQUE(game),
CHOOSE({1,2,3,4},
unique,
AVERAGEIF(game,unique,score),
MAXIFS(score,game,unique),
MINIFS(score,game,unique)))

replacing column value based in a line containing a specific string

I have text file :
file_11199_name 45 69
file_11176_name 45 69
file_11156_name 45 69
where i want change the value of column three to 1 when the first column has "11199" in the string.
the next, 3-lines, of AWK code seems to do what you need:
{c=$3}
$1~11199{c=1}
{ print $1,$2,c }
line 1 assigns a variable (c) with the value of the third column.
line 2 assigns the value 1 to c if the first variable contains 11199 ($1~11199)
line 3 prints the output
$ awk '{c=$3}$1~11199{c=1}{ print $1,$2,c }' file
file_11199_name 45 1
file_11176_name 45 69
file_11156_name 45 69

Adding B where A is same [in excel]

I want to add two rows where a variable is same.
sample.csv:
A B
corn 56
apple 43
banana 54
corn 87
mango 63
apple 67
corn 30
I want to add values of B where A is same and want to store answer in another column as follows:
corn 162
apple 110
banana 54
mango 63
Can I do this in excel? If yes, then what is the formula for that? I searched a-lot but unable to reach solution.
Try,
Select an empty cell.
Go to Data - Data Tools - Consolidate
Select the range (both columns)
Press add
Tick Left column
Press ok

Variable Delimited Text in Excel

I have a string of text that I need delimited:
New Utilizers 75 28 9 66 66 79 74 69 29 21 84 75 675 20,511 45,925
Ordinarily I would just use a space delimiter and I'd be all set, but this splits the "New Utilizers" string into two columns instead of one. Is there a way to start delimiting after a certain point, in this case start after new utilizers
Can you choise another delimiter? say $ or ;
if $ for example
New Utilizers$75$28$9$66$66$79$74$69$29$21$84$75$675$20,511$45,925
then split by $

Python3 ValueError: too many values to unpack with for loop

I've seen this same question asked around, but it's always with something like:
val1, val2 = input("Enter 2 numbers")
My problem is different.
I have two strings, str1 and str2. I want to compare them byte-by-byte such that the output would look something like this:
str1 str2
0A 0A
20 20
41 41
42 42
43 43
31 31
32 32
33 33
2E 21
So, I've tried various syntaxes to compare them, but it always ends in the same error. Here's one of my latest attempts:
#!/usr/bin/python3
for c1, c2 in (tuple("\n ABC123."), tuple("\n ABC123!")):
print("%02X %02X" % (ord(c1), ord(c2)))
And the error:
$ python3 test.py
Traceback (most recent call last):
File "test.py", line 1, in <module>
ValueError: too many values to unpack (expected 2)
Of course, this line:
for c1, c2 in (tuple("\n ABC123."), tuple("\n ABC123!")):
has gone through many different iterations:
for c1, c2 in "asdf", "asdf"
for c1, c2 in list("asdf"), list("asdf")
for c1, c2 in tuple("asdf"), tuple("asdf")
for c1, c2 in (tuple("asdf"), tuple("asdf"))
for (c1, c2) in (tuple("asdf"), tuple("asdf"))
All of which threw the same error.
I don't think I quite understand python's zipping/unzipping syntax, and I'm just about ready to resort hacking a low-level solution together.
Any ideas?
Okay, so I ended up doing this:
for char in zip(s1,s2):
print("%02X %02X" % ( ord(char[0]), ord(char[1]) ))
However, I notice that if I happen to have two lists of differing lengths, the longer list seems to get truncated at the end. For example:
s1 = "\n ABC123."
s2 = "\n ABC123!."
0A 0A
20 20
41 41
42 42
43 43
31 31
32 32
33 33
2E 21
# !! <-- There is no "2E"
So I guess I could work around that by printing the len() for each string, and then padding the shorter one to meet the longer one.

Resources