I'm trying to add a unique identifier in my pivot table.
Say you have this:
Apple 4
Orange 2
Apple 3
Orange 9
Banana 8
With item and quantity representing the labels respectively.
If you throw this in a pivot table and repeat labels, it would be re-arrange in alphabetical order (or really however you set it up). I want it to do this:
Apple-1 4
Apple-2 3
etc
Using the repeat item labels doesn't add this. Any ideas?
Sort your item list alphabetically
Create a new table, in the first column, use the following formula:
=A2 & "-" & COUNTIF(A$2:A2,A2)
In the second one, siomply use =B2
Populate down
Related
I have a table that looks like this:
Type Value
Movie 5
Food 3
Gas 10
Food 2
.... ....
And There's a second table I want to fill in with "Value" based on their type in the first table, so that the corresponding rows look like this:
Rent Food Movie Gas Clothing ... ( appear in specific order bc they are subcategories)
5
3
10
2
The title row is already there, so I was thinking there might be some kind of lookup method to do this? How do I do that?
your second table apperas to hold one value per row but it doesn't have a label. it does correlate to the original row number, is this by design or coincidence?
if this is by design then you can use those 2 columns, hide them if you like, get a unique list of categories by copying you r abels to a new colum, removing duplicates in the data tab, then paste special transpose in c1 to create colum headers.
so column a and b remain unchanged
row 1 contains header starting at column c
your data starts at c2
this is the formula
=Iferror(vlookup(C$1,$A2:$B2,2,false),"")
drag it down and to the right
you can copy paste special values when done to remove the formulas
for something with only a hundred or thousand cells this will be one of the easier options but i would not do this on large tables, for those i would use power query or VBA
Assuming your 1st table is in Sheet1 and 2nd table is in sheet2.. you may try to fill in Sheet2!A2
=IF(Sheet1!$A2=A$1,Sheet1!$B2,"")
and drag it all the way.. Hope you get how it works.. and what you need.
I'm trying to average groups of numbers which share a common value in one column but do not have a consistent number of rows. Simplified example of the problem below:
ID Value
Cat 2
Cat 3
Cat 5
Cat 8
Dog 1
Dog 6
Dog 3
Fish 3
Fish 9
So I'd like to find a single average of the values for each of the groups Cat, Dog, and Fish.
Note: I have just over 13,000 rows and 596 unique IDs shared amongst those 13,000 data (all positive decimals).
Select your data.
Go to Insert, Pivot Table
Select a destination for the Pivot Table
Drag the fields from the field list such that ID is a Row Label and Value is in the Values section:
Click on the downward arrow beside the Value field and click on Value field Settings.
Change the Summarise operation to Average.
Say I have a column with these values on Sheet1:
IDs
1
2
3
4
5
6
Then a column with these values on Sheet2:
Used IDs
2
3
6
Is there a clever way I can write a formula on Sheet3 that shows only the IDs that are visible on Sheet1 but NOT on sheet2? Like this:
Unused IDs
1
4
5
I need something that would update dynamically as move values are added to the
Used IDs' column on Sheet2. I can make something work that simply omits the used IDs (retaining their rows as NULL), like this:
Unused IDs
1
4
5
However, I need something without the blank rows.
put this in A1 in Sheet3 and copy down till blanks:
=IFERROR(INDEX(Sheet1!A:A,AGGREGATE(15,6,ROW(Sheet1!$A$1:$A$6)/(NOT(ISNUMBER(MATCH(Sheet1!$A$1:$A$6,Sheet2!A:A,0)))),ROW(1:1))),"")
I have the following source table
Date | fruit | veg
The user has previously filtered the date by month. In another table, I want to count the number of apples and tomatoes for example. To remove the invisible rows I use the SUBTOTAL function as
=(SUBTOTAL(102;OFFSET(limiter;ROW(limiter)-MIN(ROW(limiter));;1;1)))
where 'limiter' is the date range.
Then to count the number of apples in the fruit column , I use
= SUMPRODUCT(SUBTOTAL(102;OFFSET(limiter;ROW(limiter)-MIN(ROW(limiter));;1;1)) * Table!fruit = "apple"
and it works fine.
But, if I want to add in the vegetables criteria along with the fruit, the result is 0. I tried doing the sumproduct of fruit and veg first and then add the subtotal function but it gave a huge number.
Have you considered using a pivot table? (I strongly recommend you to)
Go to a new tab, select A1 and insert, new pivot table. You can put the fruit field in the column (probably row labels - my excel is in Portuguese =/). You would instantly have a table containing as first colum the list of existing fruits.
Then add the date to the body (probably values) of the pivot table and certify the type of value shown is count.
You would intantly get the count of all fruits.
The great advantage is that you can play around with this table as easily as dragging and dropping fields in columns, rows and body/values and instantly getting the results you want without having to figure out any formula issues.
Pivot tables also allow you to filter not only the date, but any other fields you wish.
I have Excel Data like below
JID Val
1001 22
1030 6
1031 14
1041 8
1001 3
2344 8
1030 8
2344 6
1041 8
How do i get the unique JID values like below using formula?
UJID
1001
1030
1031
1041
2344
Here is a solution to get a list of unique items from your tables
There is two parts to this solution.
Part 1) Unique Count
{=SUM(IF(FREQUENCY(IF($A$2:$A$10<>"",MATCH($A$2:$A$10,$A$2:$A$10,0)),ROW($A$2:$A$10)-ROW($A$2)+1),1))}
This will count the number of unique items in your data table and will ignore any blanks
*Note this is an array formula and you will need to use "Ctrl" + "Shift" + "Enter" to use
Part 2) Unique List
This formula will give you the list of unique items in your table
={IF(ROWS($E$5:E5)>$E$2,"",INDEX($A$2:$A$10,SMALL(IF(FREQUENCY(IF($A$2:$A$10<>"",MATCH($A$2:$A$10,$A$2:$A$10,0)),ROW($A$2:$A$10)-ROW($A$2)+1),ROW($A$2:$A$10)-ROW($A$2)+1),ROWS($E$5:E5))))}
again this is an array formula. You can then drag this formula down to get all the unique items.
This formula is a dynamic formula, meaning you can set the data range past your current data range and the list will update as you enter new values.
*Here is a great video to watch to understand this further
https://www.youtube.com/watch?v=3u8VHTvSNE4
You can use the remove duplicate function
Select the column range
Go to Data Tab
then click on Remove Duplicates
I think I've found a more elegant workaround without array-functions or built-in functions:
1st column (ID):
this is the array from we'd like to select distinct values
2nd column (criteria):
checks whether this is the first occurrence
=IF((ROW()-1)=MATCH(A2,$A$2:$A$500,0),1,0)
3rd column (cumulative):
=SUM($B$2:B2)
4th column (count):
this is constant 1
5th column (unique ID):
=OFFSET($A$2,MATCH(ROW()-1,$C$2:$C$501,0)-1,)
6th column (count):
=SUMIF(A2:A21,F2,D2:D21)