Specific transpose in Excel 2010 - excel

I would like to transform this:
id brand color price
1 bmw white 100
2 fiat black 200
3 audi blue 300
into this
id value
1 bmw
1 white
1 100
2 fiat
2 black
2 200
3 audi
3 blue
3 300
Headers (id, title...) are not important, all I need are values.
I've been searching for a solution for some time now, but can't find any.
Thanks for you help!

You can do this with Excel formulas. Assuming that your data are in cells 'A2:D4' and that your results begin cell F2, the following OFFSET formulas will transform the data as you want:
The first formula would begin in cell F2. This is the formula that gets and repeats the id:
=OFFSET($A$1,INT((ROW(F2)-ROW($F$2))/3+1),0)
The second formula would begin in cell G2. This one traverses the columns of the data:
=OFFSET($B$1,F2,MOD(ROW(F2)-ROW($F$2),3))
Both would be copied down as far as would be needed to transpose all the data.

Related

Determine the max value of a group, and display that row

I've got a few thousand rows in an excel spreadsheet, which (simplified) looks like this:
ID Category Animal Version Value
100 A Dog 1 20
100 B Cat 2 50
100 C Dog 3 50
200 A Dog 1 100
200 A Cat 2 100
300 B Cat 1 80
400 C Dog 1 80
I need to have the row with the highest/max version for each group of ids listed.
So in other words, I'd want these showing:
ID Category Animal Version Value
100 C Dog 3 50
200 A Cat 2 100
300 B Cat 1 80
400 C Dog 1 80
Is this possible?
Finding and showing the maxima/minima for grouped data with a single formula in only one cell can be done with the following formula:
=UNIQUE(FILTER(MyArray,MMULT(((ValueRange>TRANSPOSE(ValueRange))+(ValueRange=TRANSPOSE(ValueRange))-(GroupRange=TRANSPOSE(GroupRange)))*(GroupRange=TRANSPOSE(GroupRange)),SEQUENCE(ROWS(GroupRange),1,1,0))=0),FALSE,FALSE)
For an example, see this screenshot: Link
The output automatically adjusts for any number of groups in the data array.
With the operator > used in the formula, it will return the maximum. By using < it will return the minimum.
Note that the UNIQUE() function will only show distinct rows for each group maximum (see group 'Alpha' in screenshot).
If there is more than one maximum in a group and more than just the group and value column, the UNIQUE() function will show all distinct rows taking into account all columns (as can be seen for group 'Alpha' and 'Gamma' here: Link).
You can use the Advanced Filter with a formula criteria:
=D9=AGGREGATE(14,6,1/(A9=Table1[ID])*Table1[Version],1)
where D9 is the location of the first entry in the Value Column
Before applying Filter
After applying Filter
Suppose your data is in range A1:E8,
In cell A11, put in the following formula to find unique ID, drag it down until there is a #N/A error:
=INDEX($A$2:$A$8,MATCH(0,INDEX(COUNTIF($A$10:A10,$A$2:$A$8),0),0))
In cell B11, put in the following formula and drag it down to find the latest Version:
=AGGREGATE(14,6,$D$2:$D$8/($A$2:$A$8=A11),1)
In cell C11, D11 and E11, put in the following formulas respectively and drag them down to find the corresponding Category, Animal and Value:
=INDEX($B$2:$B$8,MATCH(1,INDEX(($A$2:$A$8=A11)/($D$2:$D$8=B11),0),0))
=INDEX($C$2:$C$8,MATCH(1,INDEX(($A$2:$A$8=A11)/($D$2:$D$8=B11),0),0))
=INDEX($E$2:$E$8,MATCH(1,INDEX(($A$2:$A$8=A11)/($D$2:$D$8=B11),0),0))
Let me know if there is any question. Cheers :)
For a list without duplicates you can put this in cell G2 ARRAY-FORMULA: CTRL + SHIFT + ENTER
=IFERROR(INDEX(A:A,MATCH(1,(COUNTIF(G$1:G2,A$1:A$99)=0)*(A$1:A$99<>""),0)),"")
This gives you a list with unique ID's. Now you can use the max formula to get the max version number of each ID. ARRAY-FORMULA: CTRL + SHIFT + ENTER
=MAX(IF($A$2:$A$2000=G3,$D$2:$D$2000,0))
The rest can be done with INDEX/MATCH formulas.

Excel: How to add a column from other sheet based on a key column?

I have 2 list. Both have a lot of column. I would like to insert a column from Sheet2 to Sheet1 based on a ceratin key column. Also sheet2 have much more rows than sheet1 so it ll be inserted only partly and still there ll be elements with no matches. For an example:
Sheet1:
Names ID Car Color
John 1 Audi Empty
Andy 4 Toyota Empty
Mike 3 BMW Empty
Tony 2 Suzuki Empty
Sheet2:
ID Cost Color
6 200 Blue
3 200 Red
4 300 Green
5 100 Red
1 50 Black
I would like to get the "color" from Sheet2 to Sheet1 by using the "ID". Using Excel 2010. I suspect I need INDEX+MATCH combination, but the examples I can find are not detailed and more simple so I coudn't figure out how to use them.
How about inserting this formula on Column D in the first row, then dropping the formula down:
=VLOOKUP(B1,Sheet2!$1:$1048576,3,FALSE)
Or to find the column that contains "Color", use Index Match Match, as follows:
=INDEX(Sheet2!$1:$1048576,MATCH(Sheet1!B2,Sheet2!A:A,0),MATCH("Color",Sheet2!$1:$1,0))
This will find the value in Column B in Sheet2 and give you the row number, then it will find the Column that contains "Color" and return the Column number, with those two numbers Index will return your color.

How to extract values based on criteria in a single column in Excel

I am trying to extract a unique value from a pivot table from a separate sheet in an Excel workbook based on criteria from a single column.
In the example below, I want to extract the number of trucks sold based on make and color. I use the following array formula and one condition works (Ford, Yellow) and the other one does not (Dodge, yellow). Am I using the correct formula? Why does it only work for "Ford", but not for "Dodge"? Is this even possible using pivot tables in separate sheets? Thank you in advance.
{=INDEX($A$2:$B$9,MATCH(A13,$A$2:$A$9,0)*MATCH(B13,$A$2:$A$9,0),2)}
A B
1 Total Sold
2 Ford 49
3 Blue 20
4 Red 13
5 Yellow 16
6 Dodge 37
7 Blue 30
8 Red 6
9 Yellow 1
Inputs Outputs
Ford Yellow 16
Dodge yellow #REF!
Ford Blue 20
You can use
=GETPIVOTDATA("Sold",A1,"Truck",A13,"Color",B13)
where Truck, Color and Sold are the column names of your pivot table data.
Or try something like
=INDEX($B$2:$B$9,MATCH(A13,$A$2:$A$9,0)+MATCH(B13,{"Blue","Red","Yellow"}))

Count how many distinct values (or get list of distinct values) in a filtered column

Is there a way to count the number of distinct values in a filtered column in Excel?
Using the formula at https://exceljet.net/formula/count-unique-values-in-a-range-with-countif I can count the number of distinct values in a range, but when that range has been filtered with an auto-filter I still get the unfiltered count.
For example:
A B
1 Scarf Blue
2 Hat Red
3 Gloves Green
4 Coat Blue
5 Balloon Red
6 Shoes Blue
Counting unique values in B with =SUMPRODUCT((B1:B6<>"") / COUNTIF(B1:B6,B1:B6 & "")) should return 3 as the distinct values are Red, Green and Blue.
If I auto filter Column B to just select Red items, the resulting table will look like:
A B
2 Hat Red
5 Balloon Red
In this case the number of distinct values retuned should be 1. But the formula above still returns 3.
The formula should also cope with multiple selections in the auto-filter, so for example filtering for Blue and Green should result in the following table:
A B
1 Scarf Blue
3 Gloves Green
4 Coat Blue
6 Shoes Blue
From which the formula should return 2 (Blue, Green).
Finally, if I am filtering on column A rather than B, the formula should still work. So If I am only interested in Hat, Scarf and Coat, filtering column A for these values would result in:
A B
1 Scarf Blue
2 Hat Red
4 Coat Blue
From which the formula should return 2.
(I'm using Excel 2013 and need to do this in a formula rather than using VBA etc)
I also found this page on office.com which I thought might help, but alas I can't get it to work for me.
This reference shows how you can exclude hidden rows using AGGREGATE
Excluding hidden rows with AGGREGATE
You can then use a standard way of counting unique values like this
Counting unique values with FREQUENCY
So if you were counting values in column B, you would need a helper column (say C) containing
=IF(AGGREGATE(3,5,B2),B2,"")
Then plug in the form of count unique that ignores empty cells
=SUM(IF(FREQUENCY(IF(LEN(C2:C10)>0,MATCH(C2:C10,C2:C10,0),""), IF(LEN(C2:C10)>0,MATCH(C2:C10,C2:C10,0),""))>0,1))
Or your formula if you prefer
=SUMPRODUCT((C2:C10<>"") / COUNTIF(C2:C10,C2:C10 & ""))

excel - count blanks per row filtered on name

Greeetings
I am trying to create a formula in excel for counting blank cells (that is the easy part ;))
But I would like to find the number of blank cells per Name in RowA.
Sheet1
A B
1 *Name* *Data*
2 Brian data1
3 Niels data1
4 Kurt data2
5 Kurt
6 Brian data3
7 Brian
8 Niels data2
Should result in:
Sheet2
A B
1 Name Percent Empty Cells
2 Brian 50%
3 Niels 0%
4 Kurt 50%
since 50 percent of Brians fields are empty.
since 50 percent of Kurts fields are empty.
Anyone?
To count the empty cells, assuming that F2 is the name value you want to look up:
=COUNTIFS(A:A,F2,B:B,"")
To get the percentage of empty cells:
=COUNTIFS(A:A,F2,B:B,"")/COUNTIF(A:A,F2)

Resources