Vlookup max / min of multiple results - arrays

I have a list of values in EXCEL
X Y
5 3000
5 3200
5 2800
10 1600
10 2900
10 3500
15 1800
15 4500
I want to get the list of X without duplicates and corresponding MIN / MAX values Y. Something like this for MAX values:
X Y
5 3200
10 3500
15 4500
How do I proceed?

A simple pivot table will do that.
Insert Pivot Table
Drag X to the rows area
Drag y to the Values area twice
Adjust value settings for one Y to MAX
Adjust value settings for one Y to MIN

Have a look at PowerQuery:
Select any cell within your data range.
Click the Data tab, then > From Table/Range.
If prompted, in the From Table dialog box, you can click the Range Selection button to select a specific range to use as a data source.
If the table or range of data has column headers, you can check My table has headers. The header cells are used to define the column names for the query.
Within PowerQuery AKA Get&TransForm
Click the Transform tab, then > Group by.
In the dialog box, click Advanced and under Group by you choose X
Choose a New column name, e.g.: maxVals. Furthermore choose Max as an Operation and under Column you choose Y.
Confirm through OK and close PowerQuery.
You'll now end up with your desired output. Replicate this for the minVals.

For MAX values you could sort your data: column X ascending & column Y descending and then apply an advanced filter (only to column X), checking the option for unique values only for MIN values you repeat the process but specify ascending as the sort order for column Y
Recording macros of these actions will provide you with the VBA code, which you should be able to make dynamic as you are asking your question in a Lecture after the Sections on Variables and Range References.
I hope this will be helpful

Related

Google Data Studio, how to get a sum of all Max or Min values

I am working with a data set where i have to get Min or Max for different text fields. My dataset can have thousands of rows so below is a simpler example. So I have 3 categories having multiple values and I can put this dataset in GDS to build a table where I select Category as dimention and Value as Max(Value) in metric.
Now I need to see the sum of all those values too. But like the pivot table in excel, the subtotal in GDS shows the Max out of all the max listed above. So instead of 65, it shows 30 in GDS. Is there a way I can get it to show the sum?
To reach the desired result you will need:
Make a data combination, not being necessary to insert a second base, just so that a current base is defined as a data combination.
In the combination use the Category dimension and define the Max Value metric. The combination is only necessary for the metric to be used in the table as a dimension (this is a property resulting from the combination of data).
Configure the table with the Category dimension and Include the metric with the Value sum option. Remember that now Value is the maximum value (as defined in the data combination).
Finally, display the Summary line. And the desired result is obtained

How to get array with values into one column

In excel I have two columns (A and B) filled with text values and I want to get all the values from the two column into one column (C) and it needs to be dynamic
example:
Column A: {car, plane, boat}
Column B: {bike, motor}
Column C: {car, plane, boat, bike, motor}
I hope someone can help me!
use:
=QUERY(FLATTEN(A:C); "where Col1 is not null")
This will work in both Excel(any version) and Google Sheets: Put this in C1 and copy down till you have enough cells filled to capture both lists maximum lengths:
=INDEX(A:B,IF(ROW($ZZ1)>COUNTA(A:A),ROW($ZZ1)-COUNTA(A:A),ROW($ZZ1)),IF(ROW($ZZ1)>COUNTA(A:A),2,1))&""
With Office 365 Excel:
=LET(
rng1st,A:A,
rng2nd,B:B,
cnt1st,COUNTA(rng1st),
cnt2nd,COUNTA(rng2nd),
sq,SEQUENCE(cnt1st+cnt2nd),
INDEX(CHOOSE({1,2},rng1st,rng2nd),IF(sq>cnt1st,sq-cnt1st,sq),IF(sq>cnt1st,2,1)))
Put that in C1 and the results will spill automatically:
Google Sheets has a FLATTEN function which allows you to do this, but there is no equivalent function in Excel.
There is a workaround though, which does combines the 2 columns in the order of their rows:
This works in Excel Version 2019 or later
=FILTERXML("<a><b>"&TEXTJOIN("</b><b>",TRUE,A:B)&"</b></a>","//b")
=IF(SEQUENCE(ROWS(range1)+ROWS(range2))<ROWS(range1)+1,range1,INDEX(range2,MOD(SEQUENCE(ROWS(range1)+ROWS(range2),,ROWS(range2)-ROWS(range1)),ROWS(range2))+1,SEQUENCE(1,COLUMNS(range2))))
This will stack range2 under range1 in Excel (365) this also works for ranges with 2 columns, or more
If the amount of the rows won't be changed
=IFERROR(INDEX($A$1:$A$3, ROWS(C1:$C$1)), IFERROR(INDEX($B$1:$B$2, ROWS(C1:$C$1)-ROWS($A$1:$A$3)), ""))
ctrl + shift + enter
If the amount of the rows can be changed
=IFERROR(INDEX(INDIRECT("$A$1:$A$"&COUNTIF(A:A,"")), ROWS(C1:$C$1)), IFERROR(INDEX(INDIRECT("$B$1:$B$"&COUNTIF(B:B,"")), ROWS(C1:$C$1)-ROWS(INDIRECT("$A$1:$A$"&COUNTIF(A:A,"*")))), ""))
ctrl + shift + enter

How to control how many cells are triggered in Google Sheets

If I have column A receive 1000 rows of input and column B has some function that takes column A cells as input for some custom function. How do I control how many cells in column B can run at a time? For example
Column A receives input into rows 1-1000. Column B has rows 1-5 trigger. In order words, how to setup concurrency control for columns?
Edit: Referring to the picture - I will paste in 1000 cells of data into column A. I need column B to only process X rows/cells at a time.
based on your picture... if you want to process only 20 rows out of 1000 you could maybe try:
=ARRAYFORMULA(FUNCTION(A1:A20))
ofc if your Function supports the ArrayFormula variation

How to count unique occurrences with criteria in excel

I'm using the below array formula to count the unique occurrences of text in column C using the agent name in column G as the reference. This is giving me multiple issues.
=SUM( --(FREQUENCY(IF(G3:G100000 = J5,MATCH(C3:C100000,C3:C100000,0)),ROW(C3:C100000) - ROW(C3) + 1) > 0))
Depending on the data set I'm using multiple agents will return a #N/A result and I can't figure out why.
Each dataset I'm using is 20k to 30k lines, so the formulas take a long time to process.
Any ideas how I could do this faster or better? Also any ideas why some agents get bad returns?
I am assuming that you are looking for the number of unique combinations of columns C and G.
Create a pivot table and check the box to add this data to the data model.
Drag both column headers to the Rows section, also drag one (of those same two) into the the values section.
click on the the field in the values section > value field settings > summarize values by > choose Distinct Count. This removes all duplicates.
Click the Row Labels filter and uncheck the blanks.
You can drop in new data then right-click on the pivot and refresh to see the new results. See the image.

Excel quartile function with variable array criteria (like countif)

hoping someone can help with my Excel query.
I want to use the quartile function (or similar, could use percentile if that's easier). I have data in a column but I want to limit the data I use from that column.
I have job departments in column A, people's salaries in column B (and other data in the other columns e.g name).
I want to use my one main data list (c. 2,000 rows) to pick out the quartiles for the 10 or so depts I have but I don't want to have to make 10 specific lists to calculate the quartile of each dept.
Is there an option to use a countif or similar function so that I can have a drop down list of my 10 depts and depending on what dept I select my summary table will show the quartiles relevant for just that dept?
Thanks
Use an array formula =quartile(if(A1:A1000=C2,B1:B1000),.75) press control + shift + enter after entering the formula. Note: C2 = the department which quartile you are calculating.

Resources