Use array formula with index match - arrays

Is it possible to do an array formula with index match:
e.g:
=arrayformula(if(len(A3:A),INDEX('SheetB'!E:E,MATCH(A3:A,'SheetB'!H:H,0))))
If not, is there a solution that doesn't involve google scripts?

It seems INDEX can not return multiple values. It can not be used inside ARRAYFORMULA.
The only solution I know of is to use VLOOKUP.
See this thread :
https://productforums.google.com/forum/#!topic/docs/jVvjbz8u7A8
Example from there :
=ArrayFormula(VLOOKUP( B12:B15; H2:R32; 1; TRUE))
Cheers!

Use XLOOKUP
=ARRAYFORMULA(XLOOKUP(K2:K,R2:R,S2:S))
With XLOOKUP you can look in one column for a search term, and return a result from the same row in another column, regardless of which side the return column is on

In the OP's specific case, one can actually use VLOOKUP for its intended purpose, as a replacement for MATCH:
=arrayformula(if(len(A3:A),VLOOKUP(A3:A,{SheetB!E:E,SheetB!H:H},2,false)))
In the general case of trying to use INDEX to retrieve multiple values, it can be replaced with a kludge of VLOOKUP and SEQUENCE:
=arrayformula(VLOOKUP(A:A,{SEQUENCE(rows(B:B)),B:B},2,true))
does what would have been accomplished by
=arrayformula(INDEX(B:B,A:A))
if the latter worked as OP expected.

I know this is old now, but it turns out that INDEX() acts as a defacto ARRAYFORMULA() now. You can see a fabulous example of this on this google sheet, which shows how to use a and index(split()) to extract a particular set of text from a cell. The MK.demo tab provides a visual on how the array formula is implied with the INDEX() function.
Nowadays, using a FILTER() or QUERY() function can give the kinds of multiple vlookup the OP was looking for.

im not sure if its gonna work but i did an "IF(ISBLANK() before the INDEX(...) in the ARRAYFORMULA and it went down all the way

Related

Excel formula to search for one of multiple strings and return the string

I have names that are listed with salutations (ex. Mr. Mrs. Dr.). I am struggling with a formula that will search for the existence of those text strings, and, if one exists, return the salutation.
So, I would like the formula to look at "Dr. Nancy Briggs," and return "Dr."
Versions I have been trying include:
=IF(ISNUMBER(SEARCH({"Mr.","Mrs.","Dr."},C13)),LEFT(C13,FIND(" ",C13,1)-1),"")
=IF(OR(ISNUMBER(SEARCH("Mr.",C24)),ISNUMBER(SEARCH("Mrs.",C24)),ISNUMBER(SEARCH("Dr.",C24))),LEFT(C24,FIND(" ",C24,1)-1),"")
the salutations are always at the front, so I can extract them using the LEFT function. But, ideally, I would like to extract them from anywhere.
The second formula works, but is clunky. Your help is so very much appreciated!
You can use a nested IF:
=IF(ISNUMBER(SEARCH("Mr.")),"Mr.",IF(ISNUMBER(SEARCH("Mrs.")),"Mrs.",IF(ISNUMBER(SEARCH("Dr.")),"Dr.","No Salutation")))
If you have OFFICE 365:
You can use CONCAT as an Array formula:
=CONCAT(IF(ISNUMBER(SEARCH({"Mr.","Mrs.","Dr."},C13)),{"Mr.","Mrs.","Dr."},"")
Being an array formula it needs to be confirmed with Ctrl-Shift-Enter instead of Enter
Or IFS()
=IFS(ISNUMBER(SEARCH("Mr.")),"Mr.",ISNUMBER(SEARCH("Mrs.")),"Mrs.",ISNUMBER(SEARCH("Dr.")),"Dr.",TRUE,"No Salutation")
The only real changes is that I am not trying to pull the return from the string as you only want the actual salutation.

How to query two consecutive "criteria rows" with DGET in Excel?

where DB.VALORI function is DGET in english.
For the queries, the rule is that the criteria row must be under the label row.
The query 1 is ok, is there a way to add query 2?
I personally don't use this DGET function but someone can probably help you here. This is another way you can try with an array formula (click Ctrl + Shift + Enter together):
=INDEX($D$2:$D$5,MATCH(G2&H2&I2,$A$2:$A$5&$B$2:$B$5&$C$2:$C$5,0))
This can do multiple matches and find the result you want. Give it a shot and let me know if you have any question.
P.S. You will need to translate the formula function to your language and doesn't forget to change , to ; in the formula.

a function calculate has been used in a true/false expression that is used as a table filter expression which is not allowed

I have a to check the current month and current year value for a measure in ssas tabular model but due to type mismatch i am not able to do this. For this, i have created a measure in which i am using this dax query
:CurrMonthYear:=CONCATENATE(CONCATENATE("""",concatenate(year(now()),CONCATENATE(0,month(now())))),"""") output: "201704"
...to calculate currentyear and currentmonth. But when i give this value in a measure like this:
SumOfRevisedForecast:=CALCULATE(SUM(DimRevisedForecast[RevisedForecast]),DimRevisedForecast[Approved] <>"N" && DimRevisedForecast[Approved] <>blank(),'DimRevisedForecast'[CalendarYearMonth] =CurrMonthYear)
...this doesnt work. Though, giving "201704" in place of CurrMonthYear works.
Can anybody help me in this?
Thanks in advance
The problem is not with CurrMonthYear measure, it's with your second formula - CALCULATE function does not accept measures as criteria, only values. That's why it works when you put "201704" explicitly but fails when you use the measure.
A common solution is to wrap the criteria into FILTER function, something like:
CALCULATE(SUM(DimRevisedForecast[RevisedForecast]),
FILTER ('DimRevisedForecast',
'DimRevisedForecast'[CalendarYearMonth] = [CurrMonthYear])
A great explanation of this issue is here:
FILTER() – When, Why, & How to Use It

Trouble with ARRAYFORMULA for auto-filling formulas in Google Sheets

I'm attempting to automatically populate a Google Sheets column in a "Results" sheet with the following formula, which draws data from a "Source" spreadsheet:
=IFERROR(INDEX(Source!$B$2:$D,MATCH($A2&C$1,Source!$B$2:$B&Source!$C$2:$C,0),3)," ")
When I place that formula in ARRAYFORMULA, it does not auto-populate, and changing the MATCH search_key to a range (i.e., $A2:$A&C$1) does not fix the problem.
I.e., neither of these work:
=ArrayFormula(IFERROR(INDEX(Source!$B$2:$D,MATCH($A2&C$1,Source!$B$2:$B&Source!$C$2:$C,0),3)," "))
=ArrayFormula(IFERROR(INDEX(Source!$B$2:$D,MATCH($A2:$A&C$1,Source!$B$2:$B&Source!$C$2:$C,0),3)," "))
Is there a way to fix this? Or an alternative way to automatically fill a formula? I'm also open to using a function other than INDEX/MATCH, so long as it can do a lookup based on two vertical criteria. Unfortunately I don't think a pivot table would suit my purposes, since my "Results" page also queries another spreadsheet to provide other information.
Example here: https://docs.google.com/spreadsheets/d/1dsaMYsJeZl2o_rNTLwaVhnEehFvAKRMXghAJeEK220s/edit?usp=sharing
This is the formula you are looking for:
=ARRAYFORMULA(IFERROR(HLOOKUP(Source!$D$2,Source!$D$2:$D$11,MATCH($A2:$A4&C$1,ARRAYFORMULA(Source!$B$2:$B&Source!$C$2:$C),0),0),0))
I tested this and it works perfectly fine.
TL;DR
To answer why your formula is wrong,
The second argument in MATCH should have an ARRAYFORMULA otherwise you are basically matching only with first element.
INDEX doesn't work with ARRAYFORMULA. It can only search for a single value in a given range.
The first part can be solved by adding ARRAYFORMULA inside MATCH.
A simple VLOOKUPcould have solved the second problem if you weren't searching for a combination of cells (Date and Name). A twisted HLOOKUP comes to your rescue.
Without the IFERROR part, the formula looks like this:
=ARRAYFORMULA(HLOOKUP(Source!$D$2,Source!$D$2:$D$11,MATCH($A2:$A4&C$1,ARRAYFORMULA(Source!$B$2:$B&Source!$C$2:$C),0),0))
This formula produces the same output (see cell I1):
=QUERY({Source!A:D,ARRAYFORMULA(VLOOKUP(Source!B:B,'Project Lookup'!A:B,2,0))},"select Col2,Col5,sum(Col4) where Col1 is not null group by Col2,Col5 pivot Col3")

Drupal 7 EntityFieldQuery OR Condition

I've got a query going using EntityFieldQuery. I have two fields called field_tags and field_categories the column name I'm looking at in each is tid. I want to check each field for a matching tid. Each one is checking a separate array of tids.
Normally I would use something like:
$query->fieldCondition('field_tags', 'tid', $my_tags, 'IN');
But now, since I'm checking if there are any matches in the tags array for field_tags OR the categories array for field_categories, I don't know how to do it. The idea is that each row returned must match at least one tag or one category.
I know there has to be an OR condition in there somewhere...
Thanks,
Howie
Found this: http://treehouseagency.com/blog/fredric-mitchell/2012/02/21/or-queries-entityfieldquery which explains how to use a tag to later the query and incorporate an OR clause.

Resources