How to separate unique values in column and put all corresponding rows in a single row - excel

I have a data set that looks something like this-
Item
Value
A
1
A
2
A
3
B
1
B
2
B
3
C
1
C
2
And I want to convert it to this -
Item
Value
A
1,2,3
B
1,2,3
C
1,2

Using your provided example data, and assuming a data setup like this:
In cell D2 and copied down is this formula to get unique items: =INDEX($A$2:$A$9,MATCH(0,COUNTIF(D$1:D1,$A$2:$A$9),0))
In cell E2 and copied down is this formula to get the joined values: =TEXTJOIN(",",TRUE,REPT($B$2:$B$9,$A$2:$A$9=D2))
Adjust the ranges to suit your actual data.

Related

Array formula with another array as input

I'm trying to get a dynamic range to use on dropdown lists in excel, I was not able to use the traditional solutions as I'll have several lines where I need this validation, and that would need me to create a "buffer" column for each entry and I want to avoid that.
Here's my Data table:
Item
Vendor
B123
A
B123
B
B321
C
B321
D
B456
E
This starts in cell A1 and is formmated as a Table called ItemList.
Then I have the following formula on cell D1. My output is a horizontal list with the unique entries of the Item column
=TRANSPOSE(UNIQUE(ItemList[ITEM]))
Then on cell D2 I have the below:
=FILTER(ItemList[Vendor];ItemList[ITEM]=D1)
Which is then expanding the values A & B below B123. However I'd like it to also work on all the spilled range of D1.
This is my current output:
B123
B321
B456
A
B
This is my desired output:
B123
B321
B456
A
C
E
B
D
Any ideas? I tried adding D1# instead of D1 in D2 formula, but no good.

Use SUBTOTAL only where column contains a value

I am currently using the following subtotal SUBTOTAL(9,b:b) to cat a total on my filtered data.
Column A contains a year of either 16,17,18 or 19.
I would like to only count the subtotal if column A contains 16 so
=if(a:a = 16, SUBTOTAL(9,b:b) or something simular
We can "fake" the SUBTOTAL() function. Say we have data like:
and we want to filter the data and only add values in column B that correspond to 16 in column A. In C2 enter:
=SUBTOTAL(3,$B2:$B2)
and copy downward. Then filter column B for positive only:
The cool thing about column C is that it is 1 if the row is visible and 0 if the row is hidden. Therefore:
=SUMPRODUCT((B2:B20)*(C2:C20))
will yield the same result as =subtotal(9,b:b) and:
=SUMPRODUCT((A2:A20=16)*(B2:B20)*(C2:C20))
will apply the column A restriction.

Rank like Subtotals

It's possible use Rank like Subtotals, that only use de showing data?.
If I filter data by a column, I want than Rank function only use these datas
Example
A B C The column C its Rank of column B
a 5 3
b 9 1
a 2 4
c 7 2
Now if I apply a filter in column A for value 'a'
A B C I want the rank recalculate with this new data
a 5 1 --> column C change from value 3 to value 1
a 2 2 --> column C change from value 4 to value 2
Thanks
You cannot do it by using RANK() formula, but you can create customizable rank formula. For this, You should add column at the and of table to indicate the row visibility, and put this formula into this column:
=(AGGREGATE(3;5;B2)>0)+0
Then put this formula into column C:
=SUMPRODUCT(($B$2:$B$9<B2)*($E$2:$E$9=1))+1
To check real example, download my sample file

Excel PivotTable; how to show values horizontally

I'm trying to rearrange a pivot table that organizes all values (not sum or other statistic) from an original table. Seems simple but I can't find a way to make it values rather than sums.
My original data looks like:
Rank Name
1 A
1 B
2 C
2 D
3 E
3 F
and with the pivot table I get something like:
Rank Name
1 A
B
2 C
D
3 E
F
and I would like to rearrange it like so:
1 2 3
A C E
B D F
There's a way to achieve that using array functions instead of pivot tables.
Suppose your original data is located in A1:B7.
To get the headers row (1, 2, 3):
A10: =MIN(A2:A7)
B10: =SMALL($A$2:$A$7,COUNTIF($A$2:$A$7,"<="&A10)+1)
Then copy B10 as far right as you need to get all other values
To get the values for each rank, set an array formula (Ctrl+Shift+Enter) on the range A11:A16 (or lower to fit more items) with this formula:
=IFERROR(INDEX($B$2:$B$7,SMALL(IF($A$2:$A$7=A$10,ROW($A$2:$A$7)-ROW($A$2)+1),ROW()-ROW(A$10))),"")
Then copy this range (A11:A16) as far right as you need...

Merge unique values if another cell matches

Merge all unique values if another cell matches. I already know how to merge cells but now some information is double. So what I would like to achieve is the following:
if column A has the same name, then all values given in column B for
that name must be given only ONCE in a new column.
My data has a row names and a row mode, for example (Row 1 is header)
A B
2 Brenda a
3 Brenda a
4 Joey a
5 Joey b
So I want:
E
2 a
3
4 a,b
5
I already did merge the modes in column 3:
=IF(A1<>A2;B2;C1&","&B2)
So I get in this example:
C
2 a
3 a,a
4 a
5 a,b
Then, I already did that only the first record get the additional modes in column 4:
=IF(A1=A2;"";INDEX(Sheet1!$C:$C;COUNTIF(Sheet1!$A:$A;$A2)+MATCH($A2;Sheet1!$A:$A;0) -1))
So I get in this example
D
2 a,a
3
4 a,b
5
Now I need a column that only uniques values are given for each name. So in this example:
E
2 a
3
4 a,b
5
If I am understanding how your data is structured, try this:
Add a new column, say column G for ease of explanation, that concatenates the name and mode in each row. So, cell G2="Brendaa", G3="Brendaa", G4="Joeya", G5="Joeyb", etc.
In your merge step you will test whether the current value in the cell for this column matches any previous values in the column: If no, you do the merge; if yes, you don't.
Your merge formula would change to something like the following:
=IF(A1<>A2,B2,IF(ISERROR(VLOOKUP(G2,G$1:G1,1,0)),C1&","&B2,""))
Then you would the next step as before.

Resources