I have 3 columns in my excel sheet - ID, Version, Material No.
for ex -
and i want the pivot table to be like -
How can i create the third calculated column because it involves two aggregation function to create it.
I am looking for count of maximum version so i need MAX function also, not count of unique values.
Consider a solution based on worksheet functions.
Assuming the table is in B5:D14,
enter an array formula, which counts unique IDs
=SUM(N($B$5:$B$14<>$B$4:$B$13))
into G2, enter
COUNT($B$5:$B$14)-G2
in H2.
Enter an array formula (
type Ctrl+Shift+Enter
instead of just Enter),
which collects unique IDs on top and fill the rest of the output lines with blanks:
=IFERROR(INDEX($B$1:$B$14,SMALL(N($B$5:$B$14<>$B$4:$B$13)*ROW($B$5:$B$14),ROW(B5)-ROW($B$4)+$H$2))*N(SMALL(N($B$5:$B$14<>$B$4:$B$13)*ROW($B$5:$B$14),ROW(B5)-ROW($B$4)+$H$2)>0),"")
in G5, another array formula
=IF(LEN(G5)>0,MAX(N($B$5:$B$14=G5)*$C$5:$C$14),"")
in H5 and one more array formula
=IF(LEN(G5)>0,SUM(($B$5:$B$14=G5)*($C$5:$C$14=H5)),"")
in I5, select range G5:I5 and drag/copy it down.
Related
I have several lists of general categories in different columns, with each category title in row 1 and each having several different items in rows below it. Picture for reference:
On this same worksheet I want to be able to enter any of the items (Pork, Apple, Cheese, etc.) in cell E2 (my lookup value). What formula can I put in cell F2 to have it return the header of the list that item belongs to (Meat, Fruit, Dairy, etc.)? With my current understanding of V/HLOOKUP and INDEX/MATCH formulas I believe you can only lookup values in a single row or , but here I want to be able to have a lookup array of multiple rows and columns, and have it return the value of the top row of the appropriate column.
Edit:
Here is what I have tried so far:
=HLOOKUP(E2,A1:D5,1,FALSE)
=INDEX(A1:D5,1,MATCH(E2,A2:D5,0))
I am using Excel 2016
The answer is to use SUMPRODUCT.
If your lookup value is in E2 and your formula in F2, use this formula:
=INDEX(A1:D1,SUMPRODUCT((A2:D5=E2)*COLUMN(A2:D5)))
This formula is not an array formula, and doesn't require the ctrl+shift+enter.
=INDEX(A1:D1,,MIN(IF(E2=A2:D5,COLUMN(A:D))))
Enter the formula with ctrl + shift + enter
MIN searches for the first TRUE where E2=A2:D5 and returns in which column A:D that was and returns that number for use in your INDEX.
I need some advice for the following task, I have an Excel sheet with 2 columns RESPONSIBLE and SERVICE (see Sheet1 of Attached file )
I need to create on another Excel sheet the matrix as Sheet2 in attached file.
Use the following array formula in B2 and drag/copy as required:
=IF(AND($A2<>"",B$1<>"")=TRUE,IF(ISNUMBER(MATCH($A2&B$1,Sheet1!$A:$A&Sheet1!$B:$B,0))=TRUE,"x",""),"")
To populate the column headers use the following array formula in B1 and drag/copy:
=IFERROR(INDEX(Sheet1!$B$2:$B$100,MATCH(0,COUNTIF($A$1:A1,Sheet1!$B$2:$B$100),0)),"")
To populate the row headers use the following array formula in A2 and drag/copy:
=IFERROR(INDEX(Sheet1!$A$2:$A$100,MATCH(0,COUNTIF($A$1:A1,Sheet1!$A$2:$A$100),0)),"")
Enter all the above formulas with ctrl + shift + enter
I tested the above formulas by increasing the data and it slowed down my excel file. The reason is most likely the first formula.
If you add a helper column in sheet1 then you can add this in C2 (not an array formula):
=A2&B2
Then in sheet2, B2 you can use (not an array formula):
=IF(ISNUMBER(MATCH($A2&B$1,Sheet1!$C:$C,0))=TRUE,"x","")
This will substantially increase the speed to normal levels as the number of array formulas in the sheet are materially reduced.
Or
You can simply use a pivot table. Enter "Service" as column label and value, and "Responsible" as row label. The value should show count of service. The only difference will be that instead of "x" it will show a 1. You will also have to refresh the pivot table whenever you update the data.
If I have a lookup table with a range of number (Min and Max) in two columns. ON the second sheet, it contains the numbers (1-100). And I'd like to lookup the row number from the lookup table. How can I do?
Consider:
=INDEX(A$2:A$11,MATCH(D2,B$2:B$11,1))
Assuming that Band is in the A-Column, Min in the B-Column and so on and the headers in the first row, put this in F2 and drag down as necessary:
{=INDEX($A$2:$A$11,MATCH(1,(E2<=$C$2:$C$11)*(E2>=$B$2:$B$11),0))}
Please note that you don't have to put in the {}, this indicates, that this is a array formula, so you have to enter this formula with Ctrl+Shift+Enter instead of just Enter.
If you have the data in different ranges, then you will have to adjust the ranges accordingly.
If you are interested in the row instead of the Band, then wrap ROW arround the formula, so:
{=ROW(INDEX($A$2:$A$11,MATCH(1,(E2<=$C$2:$C$11)*(E2>=$B$2:$B$11),0)))}
Again with Ctrl+Shift+Enter.
You can use index match.
Give the lookup table a name, for example "tbl"
Lets say numbers are in column G
Then you can use this formula:
=INDEX(tbl[band];MATCH(1;(G11>=tbl[min]) * (G11 < tbl[max]);0))
Tables
Formula
Reference:https://exceljet.net/formula/index-and-match-with-multiple-criteria
I have an Excel spreadsheet of the form:
A,B
X,1
X,5
Y,4
Y,11
X,7
Z,1
I would like to get the maximum value of column B for each distinct value of column A - how can I do it via pure Excel formula?
Desired result (order is irrelevant):
A,B
Y,11
X,7
Z,1
In other words, I would like Excel's version of an SQL query
SELECT A,max(B)
FROM myTable
GROUP BY A
Any version of Excel is acceptable, but I use 365 one.
Pivot tables are an acceptable approach (I currently did it with a pivot myself) but I would strongly prefer a real formula - the main goal of the question is to enhance my understanding of formula programming in Excel. No VBA
Gary's Student's answer is correct. I added a couple things.
Also, a link to the method:
http://blog.contextures.com/archives/2011/07/27/finding-min-if-or-max-if-in-excel/
A distinct list of values can be generated in a couple ways, here's one:
And here's links to a method or two for distinct lists. All with array formulas:
Ignore Duplicates and Create New List of Unique Values in Excel
Getting unique values in Excel by using formulas only
With data in columns A and B use the Array Formula:
=MAX(IF(A1:A6="x",B1:B6))
Same for "y" and "z"
Array formulas must be entered with Ctrl + Shift + Enter rather than just the Enter key.
Notice the braces in the Formula Bar
EDIT#1:
To generate the formulas automatically, first copy column A to column C.
Then use the Remove Duplicate feature in the Data tab:
Then enter the Array Formula in cell D1:
=MAX(IF(A$1:A$14=C1,B$1:B$14))
and copy down:
The formula is only entered once and then copied down!
Pivot table is the correct answer.
Select column A's title and drag it to the Row Labels section.
Select column B's title and drag it to the Values section.
Click the arrow on column B's title in the values section and choose Value Field Settings.
Select Max
Try below. Note I moved your desired output table to Columns D and E. You will not need to hard-code any values into formulas.
Data
D E
Y 11
X 7
Z 1
Formulas
E2 Formula: ={MAX(--($D1=A1:A6)*B1:B6)}
E3 Formula: ={MAX(--($D2=A2:A7)*B2:B7)}
E4 Formula: ={MAX(--($D3=A3:A8)*B3:B8)}
I am referring to below my google spreadsheet
https://docs.google.com/spreadsheets/d/1dCfShenhV2j98q5wkOXMeyWj9tlMZbaBgBqB2vAPdHo/edit?usp=sharing
I am looking to update H,I and J columns using vlook formula in way that it should match both name and date values in my data range, which in A,B and C columns
Here is the issue I am facing with normal vlookup is that I can check only name.It is ignoring the date and updating the vlooked up data on all date column.
Eg: Alpha and date 20141120 value is 10, it should fill only H3, but it is updating, H3 I3 and J3 with value 10
I really appreciate your answer on this problem!!!
you can use this formula of index and match:
=IFERROR(INDEX($A:$C,MATCH(1,($A:$A=$G3)*($B:$B=H$2),0),3),"")
paste it in the first cell of your table H3, and drag and fill to the right and then select the entire row and fill down till end.
it should work.
if error(();"") : you will get empty cells if there is no match.
this is an array formula, so press ctrl+shift+enter to calculate the formula
UPDATE: here is [the example sheet downloadable from here}(https://www.dropbox.com/s/clqxsj5j4bdk27b/indexmatch.xlsx?dl=0)
Basically you need to concatenate the results, then use a VLOOKUP on that.
I.e. insert a column between B and C, with formula "=CONCATENATE(A2,B2)"
In the range you want to update, use the column and row headings for you lookup
"=VLOOKUP(CONCATENATE($g3,h$2),$c$1:$d$3,2,false)"
You want to perform a Multiple Lookup (see this).
As indicated there, enter
=IFERROR(LOOKUP(2,1/($A$1:$A$3=$G3)/($B$1:$B$3=H$2),$C$1:$C$3),"")
in H3. Copy into H3:J5.
This avoids array formulas.