excel data transposition using built in formulas - excel

Heres the issue I have a dump from the database at work that is in a rather conveluted format. Basically it does not give you the displayed information as much as just the individual relation tables to work with.
EXAMPLE: lets say I have the following columns of information
ID, COLOR, SIZE, QTY, TYPE
the information looks something like this
ID COLOR SIZE QTY TYPE
A brown 20 1 1
C yellow 10 2 2
D brown 40 5 1
A blue 70 1 3
A yellow 80 1 2
B yellow 20 4 1
D blue 70 4 2
C blue 10 3 1
what i need is something more like this
ID BROWN SIZE TYPE BLUE SIZE TYPE YELLOW SIZE TYPE
A 1 20 1 1 0 3 1 80 2
B 0 0 0 0 0 0 4 20 1
C 0 0 0 3 10 1 2 20 1
D 5 40 1 4 0 2 0 0 0
I most like could accomplish this with an excel formula, possibly the one called sumifs but i can not seem to get it to work any help with this would be greatly appriciated.

You can do this by using a combination of SUM and IF in array formulas.
Assuming that your data table starts in cell A1 and your result table starts in cell A11, begin by entering the following formulas in cells B12, C12 and D12 respectively, making sure to use the CONTROL-SHIFT-ENTER key combination to enter them.
B12 =SUM(IF($B$2:$B$9=B$11,IF($A$2:$A$9=$A12,$D$2:$D$9,0)))
C12 =SUM(IF($B$2:$B$9=B$11,IF($A$2:$A$9=$A12,$C$2:$C$9,0)))
D12 =SUM(IF($B$2:$B$9=B$11,IF($A$2:$A$9=$A12,$E$2:$E$9,0)))
Copy the cells down to the bottom of your data table, which in this example would be row 15.
Then copy the block of formulas you have created to cell E12, where the BLUE section of the result table starts. Then copy the same block of formulas to cell H12, where the YELLOW section of the result table starts.
This solution assumes that you have no duplicate combinations of ID and COLOR in your data table and that no combinations are missing. If there are missing combinations of ID and COLOR, you would need to wrap the formulas in an IFERROR function (in Excel 2010).

The way I'd transpose a data table would run like this...
Your example is a bit more complicated so I'm not going to use your full data, just go with size. Begin by creating a column called Index
A B C D
INDEX ID COLOR SIZE
=A3 & "-" & B3 A brown 20
=A4 & "-" & B4 C yellow 10
. D brown 40
. A blue 70
. A yellow 80
. B yellow 20
D-blue D blue 70
C-blue C blue 10
Create a table equivalent which combines the header row with the ID column
F G H I
ID brown blue yellow
A =$F2 & "-" & G$1 . .
B . . .
C . C-blue C-yellow
D . D-blue D-yellow
Finally wrap this up in a VLOOKUP or an OFFSET(MATCH(_)) with possible an IFERROR
ID brown blue yellow
A =IFERROR(VLOOKUP($F2 & "-" & G$1,$A$3:$D$10,4,FALSE),"Err")
B . . .
C . 10 10
D . 70 Err
Anyway that is how I generally do this sort of transform

Related

Formula reference holds for n cells in a row, then switches to new reference

I wonder if there's a quick solution to the following:
My goal is to divide a cell value by three, using the same value for three cells in a row, then switch to the next value in the series for another three cells in a row, and so on.
So my starting data would look like:
A B C D E
1 9 12 6 21 27
2 30 9 3 0 3
3 ...
I want the new cells to look like:
AA AB AC AD AE ...
1 3 3 3 4 4
2 10 10 10 3 3
...
Where the cell AA1 = A1/3, AB1 = A1/3, AC1 = A1/3, but AD1 = B1/3 and so on.
I need to do this for many observations, preferably using an excel formula.
Does anyone have any ideas on quick solutions?
Really appreciate your help.
Best,
Henry
Use INDEX:
=INDEX(1:1,0,ROUNDUP(COLUMN(A1)/3,0))/3

Concatenating INDEX/MATCH with multiple criteria and multiple matches

I am using Excel to track a team game where players are divided into teams and subteams within teams. Each player within a subteam scores a certain number of points, and I would like to have a summary string for each player with the number of points other players in the same subteam scored.
Example:
A B C D
PLAYER TEAM SUBTEAM POINTS
Alice Red 1 70
Bob Red 1 20
Charlie Red 1 10
Dave Red 2 70
Erin Red 2 30
Frank Blue 1 55
Grace Blue 1 45
My desired output looks like this:
A B C D E
PLAYER TEAM SUBTEAM POINTS SUMMARY
Alice Red 1 70 Bob:20, Charlie:10
Bob Red 1 20 Alice:70, Charlie:10
Charlie Red 1 10 Alice:70, Bob:20
Dave Red 2 70 Erin:30
Erin Red 2 30 Dave:70
Frank Blue 1 55 Grace:45
Grace Blue 1 45 Frank:55
The furthest I was able to go is a combination of CONCATENATE, INDEX, and MATCH in an array formula:
{=CONCATENATE(INDEX($A$2:$A$8,MATCH(1,(C2=$C$2:$C$8)*(B2=$B$2:$B$8),0)), ":", INDEX($D$2:$D$8,MATCH(1,(C2=$C$2:$C$8)*(B2=$B$2:$B$8),0)))}
This unfortunately just outputs a summary for the first player in the subteam:
A B C D E
PLAYER TEAM SUBTEAM POINTS SUMMARY
Alice Red 1 70 Alice:70
Bob Red 1 20 Alice:70
Charlie Red 1 10 Alice:70
Dave Red 2 70 Dave:70
Erin Red 2 30 Dave:70
Frank Blue 1 55 Grace:45
Grace Blue 1 45 Grace:45
What I need to do now is:
Excluding the player for the summary (I don't want Alice in the summary for Alice, but only Bob and Charlie)
Getting it to work for multiple matches (there can be an arbitrary number of players in each subteam)
Getting CONCATENATE to work with an unknown number of strings (because as said above, there can be an arbitrary number of players in each subteam).
Ideas appreciated!
I put together a helper column that concatenates each player/points and the TEXTJOINIFS from TEXTJOIN for xl2010/xl2013 with criteria for the desired results.
Unfortunately Excel (prior to Excel 2016) cannot conveniently join text. The best you can do (if you want to avoid VBA) is to use some helper cells and split this "Summary" into separate cells.
See example below. The array formula in cell E4 is dragged to cell J10.
= IFERROR(INDEX($A$4:$D$10,MATCH(SMALL(IF(($B$4:$B$10=$B4)*($C$4:$C$10=$C4)*($A$4:$A$10<>$A4),
ROW($A$4:$A$10)),E$3),ROW($A$4:$A$10),0),MATCH(E$2,$A$1:$D$1,0)),"")
Note this is an array formula, so you must press Ctrl+Shift+Enter instead of just Enter after typing this formula.
Of course, in this example I assume 3 players. Your requirement of arbitrary amount of players cannot be met with formulas alone, but you can just extend the "Summary" section over to the right as far as necessary.
If you really wanted to, you could even concatenate the "Summary" rows to form a single cell, e.g. something like:
= CONCATENATE(E4,": ",F4,", ",...)

How to use Fill Handle to copy same value in the same steps of row in Excel

confuse wiht the Title
Well sorry my English doesn't look good
but I'll try to describe what I mean
Suppose I have this kind of values
0 A B C D F G H I J
1 20 =B1
2 10 =B3
3 30 =B5
4 8 =B7
5 9 =B9
6 4 etc.
7 79
8 67
9 63
10 45
as you seen above
I want to copy every value in cell B in two step down to cell D with Fill Handle
How can I do it ?
Any Formula I can use regarding this ?
Thanks before
In Cell D2 you can use the below formula, then drag down:
=INDEX(B:B,(ROWS($B$1:B1)*2)-1,1)
Please try:
=OFFSET(B1,ROW()-1,)

Join/Concatinate column text based on criteria

I have a data set like this:
A B C
----------
1 A blue
1 A red
1 B blue
2 A red
3 B blue
3 B green
3 C blue
4 C blue
4 A blue
4 A green
And a separate table like this (this is already auto generated using UNIQUE()):
E F G
-----
1 A
1 B
2 A
3 B
3 C
4 C
4 A
I want to join text from column C and show the result in column G based on a criteria given in columns E and F. The result I am looking for would look like this (all concatenated/joined text should be in column G):
E F G
-----
1 A blue red
1 B blue
2 A red
3 B blue green
3 C blue
4 C blue
4 A blue green
Optional, not needed but would be nice: The delimiter between generated text is a line brake so each line is in a separate line inside the same row.
Thank you.
place your first table (data table/ 1,2,3) in column A to C.
and another table (5,6,7) in column E to G
Enter below Array Formula in G2
{=CONCAT(IF(A2:A11&B2:B11=E2&F2,C2:C11&" ",""))}
you will get your result.
For earlier versions, we need to create UDF
Function ConcatUDF(rng() As Variant, ByVal delim As String) As String
Dim a, i As Long
For i = 1 To UBound(rng, 1)
If rng(i, 1) <> "" Then
ConcatUDF = ConcatUDF & _
IIf(ConcatUDF = "", "", delim) & rng(i, 1)
End If
Next
End Function
and we will get the result.
Edited:
I forgot to absolute the references. Please consider below mnetioned formula.
with Build in CONCAT formula for excel 2016
=CONCAT(IF($A$2:$A$11&$B$2:$B$11=E2&F2,$C$2:$C$11&" ",""))
with UDF for earlier version of excel
=ConcatUDF(IF($B$2:$B$11&$A$2:$A$11=F2&E2,$C$2:$C$11,"")," ")

How to match different charts

Below I have two charts, the first does not have the value of calories, the second does. (The values are arbitrary - this is just an example.) I need to find a way to fill in the value of the calories in the first chart by matching all the values of wheat, flour, barley, and rye with the second chart. If all the values match, then I need it to copy that number of calories into the first chart. For example, row 2 has matching values with row 13, so I need to copy 100 calories into the E2 cell.
Does anyone have a formula that can do this?
A B C D E
1 Wheat Flour Barley Rye Calories
2 1 0 0 2
3 4 2 4 0
4 1 4 5 2
5 0 3 2 1
6 1 6 8 9
10 KEY
11 A B C D E
12 Wheat Flour Barley Rye Calories
13 1 0 0 2 100
14 0 3 2 1 150
Insert a column between Rye and Calories, in E12 enter =A12&B12&C12&D12 and copy down to suit.
In F2 enter =VLOOKUP(A2&B2&C2&D2,E$13:F$14,2,0) (or extend range if required) and copy down to suit.
This assumes both arrays are in the same sheet.
Tidy up by selecting ColumnF, Copy, Paste Special..., Values over the top and then delete ColumnE.
I'm new so can't post pics... I added a column to be the new A column that details different weight measurements (1.0 grams, 1.25 grams etc)
In cell B3 (or whatever cell is directly under Wheat at the top, paste the following and then paste over and across:
+IFERROR(INDEX($B$9:$F$16,MATCH($A3,$A$9:$A$16,0),MATCH(B$2,$B$8:$F$8,0)),0)
where $B$9:$F$16 is your whole table of original data
where $A3 is your identifier in your top chart (1.0 grams in my example)
where $A$9:$A$16 is the range in your data chart that lists gram measurements (1.0 grams - 10.0 grams or whatever)
where B$2 is Wheat in top chart
where $B$8:$F$8 is Wheat to Calories in bottom chart.
Hope this helps.

Resources