find longest string in with criteria - excel - excel

I have two columns Item and ID - refer to the Sample Table. I need a formula in Excel to determine the longest (based on simple length of ID) per item.
Here is what I am trying to extract from the sample table:
Item 1 ABCDABC
Item 2 XXXYZ
I tried index match combination:
=INDEX("ID column",MATCH(MAX(LEN("ID column")),LEN("ID column"),0),MATCH("Item 1" , "Item Column",0))
with ctrl+shift+enter
here are the results:
Item 1 ABCDABC
Item 2 #REF!
Any help will be greatly appreciated.
Sample Table
Item ID
Item 1 ABC
Item 1 ABCD
Item 1 ABCDA
Item 1 ABCDAB
Item 1 ABCDABC
Item 2 X
Item 2 XX
Item 2 XXX
Item 2 XXXY
Item 2 XXXYZ

This will return the correct index:
=INDEX($B$2:$B$11,MATCH(MAX(INDEX(LEN($B$2:$B$11)*($A$2:$A$11=D3),)),INDEX(LEN($B$2:$B$11)*($A$2:$A$11=D3),),0))

A PivotTable is perfect for this, because it will handle ties.
Turn your source data into an Excel Table
Add a new column to your source data, and use the LEN function to
return the length of each item. You only need to add the formula to the top row, and Excel will copy it down using Table notation:
Make a PivotTable out of that Table, and put Item and ID in the ROWS
pane and put Length into the Values pane:
Right-click on one of the cells in the Sum of Length PivotField, and
change the aggregation to MAX:
Click the ID filter dropdown, and select Values Filter > Top 10...
In the dialog box, change the 10 in the to a 1 and click OK:
BING!
...and if two IDs within the same category have the exact same length, the PivotTable shows you both of them:

Related

Excel - Lookup date in matrix and return column heading

I have a matrix between Products and Enablers, where the intersection between the two represents a point in time.
Product list
Enabler 1
Enabler 2
Enabler 3
Product 1
10-Oct
11-Oct
20-Oct
Product 2
20-Nov
25-Nov
01-Dec
Product 3
10-Oct
21-Oct
25-Oct
I need to turn this into a 'timeline' view so visually there are two ways to see the data, where the dates are across the top and based on the timing in the first table, it returns the corresponding 'Enabler' at the correct date...something like
Product list
10-Oct
11-Oct
12-Oct
Product 1
Enabler 1
Enabler 2
Product 2
Product 3
Enabler 1
Does anyone have any ideas how I'd do this? I think it requires an INDEX MATCH array formula as it needs to look across the matrix to find the date in that row, then return what is in the header column...but this isn't my area of expertise and I just can't seem to figure out how to make it work.
One approach might be to return this as an array. You could do:
=IF( ( Table1[[Enabler 1]:[Enabler 3]] = B7:D7 ) * ( Table1[Product list] = A8:A10),
Table1[[#Headers],[Enabler 1]:[Enabler 3]],
"" )
where Table1 is an Excel Table that holds your Product List and Enablers as columns (as shown in your first table); A8:A10 is the list of products in your second table; and B7:D7 is the list of dates in your second table shown as column headers. The formula would be placed in the upper left cell of your second table - in my example, B8 as shown here:
The result will spill into the second table.
If you wanted your second table to be an Excel Table, the approach
would be different as arrays cannot spill into Excel Tables.

search min value in already summarized group in excel pivot

Example:
Region - Customer - Value
1 - a - 2
1 - a - 3
1 - b - 4
2 - d - 1
2 - d - 5
2 - c - 6
2 - c - 1
I want to show min value in certain region by summarized customer. Somehow excel should first summarize values by customer (a=5, B=4, C=7, d=6) and only than search min value by region.
Correct pivot table at the end would be:
Region - min value
1 - 4
2 - 6
To get the exact pivot table described (with only Region and Min Value columns), you need to add a helper column with the following formula (created after turning your data into a table to use table references):
=SUMIFS([Value],[Region],[#Region],[Customer],[#Customer])
Then add Region as Row Field, helper column as Data Field, then summarise values by Minimum.
Alternatively, you could generate a pivot table with the required values without a helper column, however you'll also need to also display the Customer column and apply a filter to it:
Create Pivot Table
Add Region as Row Field
Add Customer as Row Field
Add Value as Data Field
Change Report Layout to Tabular Form (PivotTable Tools > Design tab)
Remove Subtotals and Grand Totals (also on Design tab)
Right click on Customer Field in PivotTable
Select Filter > Top 10...
Set to: Show Bottom 1 Items by Sum of Value

Indexing Groups of Data

I have 10,000+ row of values which need to be indexed with a numerical value which increases by 1 every 56 rows - for example:
Rows Index Value
1-56 1
57-112 2
113-168 3
169-224 4
Any ideas?
Thanks! :-)
If your data starts in Row #2 like your example implies, then try this formula in Row #2 the column where you want your "index number":
=INT((ROW()-1)/56)+1
The 1 in the middle is "how many rows to skip at the top", and the 56 is obviously the size of each group.
More Information:
Office Support : ROW Function (Excel)
Office Support : INT Function (Excel)

I want to get the sum of count of each unique entry from a particular column from google sheet

I have a google spread sheet,I want to get the sum of count of each unique entry from a particular column('Text' in this example).However the entries in the column themselves repeat.
Eg:
Text Count
a 3
b 4
a 8
abd 4
c 1
t 2
abd 5
a 2
v 1
v 67
w 44
I want the output as:
Text Count
a 13
b 4
abd 9
c 1
t 2
v 68
w 44
Under the assumption that you want to get the results in the text column automatically, use a Pivot table in Excel:
Mark your data including the column captions "Text" and "Count"
Go to the "Insert" tab in the ribbon, hit the arrow below and choose "PivotChart and PivotTable"
The cells for the raw data should already be entered. In the lower part of the window choose where you want to get the Pivot table. Then hit Ok.
There should be an area on the right-hand side of the window where you can choose which data you want to evaluate. Choose Text and Count.
There should already be the sum of the Count values. If you want to get a different quantity such as the average, hit "Sum of Count" with the right mouse button and
You need a GROUP BY and a SUM:
SELECT text, sum(count) as count
FROM yourtable
GROUP BY text

Excel: Return a single value based on two references

I have two values that a person would enter information for in column B:
Spreadsheet Name: Info
A B
1 Level 2
2 Class Class 2
In a second spreadsheet within the Workbook, i have a data spreadsheet with various tables.
So when a person enters information in !InfoB2 data validation drop down, it would return the name of the table the formula should use to search for the value in the Data table that's level is related to !InfoB2.
Spreadsheet Name: Data
Table Name: Class 1
A B
1 Level BAB
2 --------------------
3 1 8
4 2 3
Table Name: Class 2
A B
1 Level BAB
2 --------------------
3 1 2
4 2 7
So when someone enters Level: 2, and Class2, i would like it to return the value in the BAB column, how can i do this?
Edit
As ghetto as this is, it feels like it's on the right track, however it's returning #VALUE!
VLOOKUP(B1,VLOOKUP(B2,Class,2,FALSE),2,FALSE)
Table Class
Table Name: Class
A B
1 Class Name Table Name
2 Class 1 Class1Table
3 Class 2 Class2Table
You could try the following formula:
=INDEX(INDIRECT(B2&"[#All]"), MATCH(B1,INDIRECT(B2&"[[#All],[Level]]"),0), 2)
This takes the value of B2 (Class2 note I removed the space since table names can't contain spaces) and concatenates it with [#All] so you get: Class2[#All] (this is the table reference). INDIRECT converts the text into a valid range.
INDIRECT(B2&"[[#All],[Level]]") similarly gives the range Class2[[#All],[Level]].
MATCH(B1,Class2[[#All],[Level]],0) gives the row number in which the value in B1 is found (i.e. gives the row in which 2 is found, meaning the result is 4)
=INDEX(Class2[#All], 4, 2) then returns the value from range Class2[#All] in the 4th row and 2nd column.
If I understand correctly you will want to use INDIRECT and/or the structured reference syntax for this one.
I don't have access to Excel at the moment so I can't check to see if this would work. I'll update this answer once I try some stuff out.

Resources