Arraryformula with IF - google-sheets-formula

I have a very simple formula but don't understand why it does not work?
here is my formula: ARRAYFORMULA(IF(J2:J>P2:P,P2:P,J2:J))
without array formula : IF(J2>P2,P2,J2))
Anyone can help me understand what am I missing in Arrayformula?
with or without arrayformula my output is same -->

Related

Excel cube: create new measure as sum of existing measures

I have no idea what to put in the formula box, and the help (https://support.microsoft.com/en-us/office/create-a-measure-in-power-pivot-d3cc1495-b4e5-48e7-ba98-163022a71198?ns=excel&version=90&syslcid=1033&uilcid=1033&appver=zxl900&helpid=149601&ui=en-us&rs=en-us&ad=us) says simple enter a formula.
Is there any documentation?
Neither
=SUM(dsv_FactIncome[ClientValue], dsv_FactIncome[PartnerValue])
nor
=SUMX(dsv_FactIncome[ClientValue], dsv_FactIncome[PartnerValue])
are acceptable to it, either.
This is DAX and your syntax is incorrect. Try
=SUM(dsv_FactIncome[ClientValue]) + SUM(dsv_FactIncome[PartnerValue])

Using IF, AND/OR (many condition) with Array formula in Google sheets

Could someone help me?
I'd like to use the Array formula with AND/OR as follows but it doesn't work
=ArrayFormula(if(AND(AG2:AG="Yes",AI2:AI<>""),"Ok","Blank"))
It similar to OR
How can I use this in case I need to put more than 2 conditions in the AND/OR when using the Array formula?
Thanks so much.
Do not use AND/OR with ARRAYFORMULA, use + instead of OR and * instead of AND with IF
Try
=ArrayFormula(if((AG2:AG="Yes")*(AI2:AI<>""),"Ok","Blank"))
You can add other conditions if you respect the syntax with + or *

Google Sheets IMPORTXML query

I'm using Google Sheets as web scraper.
I have been using this IMPORTXML
=importxml(A1, "//div[#class='review-content']//text()")
and this is the results
Row1: {"publishedDate":"2019-01-05T22:19:28Z","updatedDate":"null","reportedDate":"null}
Row2: {"publishedDate":"2018-12-10T22:19:28Z","updatedDate":"null","reportedDate":"null}
Row3: {"publishedDate":"2018-12-09T22:19:28Z","updatedDate":"null","reportedDate":"null}
but am having trouble figuring out how to get only the "publishedDate" value.
Example:
Row1: 2019-01-05T22:19:28Z
Row2: 2018-12-10T22:19:28Z
Row3: 2018-12-09T22:19:28Z
Any ideas as to what I may be missing
How about these 3 samples? I thought them from the samples of your question. I think that there are several answers for your situation. So please think of this as 3 samples of them.
It supposes that the URL is put in the cell "A1".
Sample 1:
=ARRAYFORMULA(MID(IMPORTXML(A1, "//div[#class='review-content']//text()"),19,20))
When the length of string of each value is the constant, how about this?
The value is retrieved by MID().
Sample 2:
=ARRAYFORMULA(INDEX(SPLIT(IMPORTXML(A1, "//div[#class='review-content']//text()"),"""",TRUE,TRUE),,4))
When the position of each value is the constant, how about this?
The value is retrieved by SPLIT() and INDEX().
Sample 3:
=ARRAYFORMULA(REGEXEXTRACT(IMPORTXML(A1, "//div[#class='review-content']//text()"),"publishedDate"":""(\w.+?)"""))
When the pattern of each value is the constant, how about this?
The value is retrieved by REGEXEXTRACT().
References:
MID
SPLIT
INDEX
REGEXEXTRACT
If these were not the results you want, I apologize. At that time, in order to correctly replicate your situation, can you provide the URL you are using as #Rubén says?

Excel - Search an exact match within a string

I'm currently struggling on finding the formula that will resolve my problem.
Here's the status quo:
In Sheet 1, column A, I have a set of string, such as:
/search.action?gender=men&brand=10177&tag=10203&tag=10336
/search.action?gender=women&brand=11579&tag=10001&tag=10138
/search.action?gender=men&brand=12815&tag=10203&tag=10299
/search.action?gender=women&brand=1396&tag=10203&tag=10513
/search.action?gender=women&brand=11&tag=10001&tag=10073
/search.action?gender=women&brand=1396&tag=10203&tag=10336
/search.action?gender=women&brand=13
In Sheet 2, column A, I have a set of strings such as:
brand=10177
brand=12815
brand=13
brand=1396
brand=11579
Finally, in sheet 1, column B will be my "filter" with the formula I'm struggling to find. The goal of my formula is to detect in any of the strings in sheet 1 if one of the string in sheet 2 is present (as an exact match!). Indeed, now it only finds approximative matches. As you can see, the row 5 shouldn't return anything. But with my current formula it does.
Here's the formula:
{=IFERROR(INDEX('Sheet 2'!$A$1:$A$5;MATCH(1;COUNTIF(A1;"*"&'Sheet 2'!$A$1:$A$5&"*");0));"")}
Any idea on the matter?
Please note that I don't want to use VBA, macros, but only a formula.
Thanks a lot for your help!
Following will solve your problem I guess:
=VLOOKUP(MID(A2,FIND("&",A2)+1,FIND("&",A2,FIND("&",A2)+1)-FIND("&",A2)-1),Sheet2!A:A,1,FALSE)
Basically with find function I have identified the start and length of the string in between "&" signs. and used in vlookup.
Another point to mention is this formula is only looking for the first 2 "&" signs.
For completeness, here is another solution based on this answer
=INDEX(Sheet2!$A$1:$A$5,MAX(IF(ISERROR(FIND(Sheet2!$A$1:$A$5,A1)),-1,1)*(ROW(Sheet2!$A$1:$A$5)-ROW(Sheet2!$A$1)+1)))
This is a bit more general and it doesn't matter how many search tags there are.
However as it stands it would match brand=13 in the second sheet with brand=1396 in the first sheet. To avoid that you could add an ampersand to the search strings:-
=INDEX(Sheet2!$A$1:$A$5,MAX(IF(ISERROR(FIND(Sheet2!$A$1:$A$5&"&",A1&"&")),-1,1)*(ROW(Sheet2!$A$1:$A$5)-ROW(Sheet2!$A$1)+1)))
This formula throws a #VALUE error if there is no match: to avoid this, you would need to put an IFERROR statement round it:-
=IFERROR(INDEX(Sheet2!$A$1:$A$5,MAX(IF(ISERROR(FIND(Sheet2!$A$1:$A$5&"&",A1&"&")),-1,1)*(ROW(Sheet2!$A$1:$A$5)-ROW(Sheet2!$A$1)+1))),"")
All these are array formulae.

Excel formula debugging - Median calculation

I need help in proper formula formatting/syntax. I just haven’t been able to debug my formula to calculate a Median. Here is a working formula that calculates an Average:
=AVERAGEIFS(OFFSET(INDEX(date_city!1:1,MATCH("Price Per SF",date_city!1:1,FALSE)),0,0,COUNTA(INDEX(date_city!1:65521,,MATCH("Price Per SF",date_city!1:1,FALSE))),1), (OFFSET(INDEX(date_city!1:1,MATCH("Date of Sale",date_city!1:1,FALSE)),0,0,COUNTA(INDEX(date_city!1:65521,,MATCH("Date of Sale",date_city!1:1,FALSE))),1)), ">" & Criteria!$F$4, (OFFSET(INDEX(date_city!1:1,MATCH("Date of Sale",date_city!1:1,FALSE)),0,0,COUNTA(INDEX(date_city!1:65521,,MATCH("Date of Sale",date_city!1:1,FALSE))),1)), "<" & Criteria!$G$4)
I need to modify the above so it calculates a Median.
I’ve tested this simpler formula for proper format and it works:
{=MEDIAN(IF((date_city!$I$2:$I$989>Criteria!$F$4)*(date_city!$I$2:$I$989<Criteria!$G$4),
date_city!$E$2:$E$221))}
I need to replace *date_city!$I$2:$I$989* and *date_city!$E$2:$E$221* from the above Median formula with their corresponding code from the Average formula.
I tried this code, but cannot find my errors. Probably incorrect parantheses or comma placement.
=MEDIAN(IF((OFFSET(INDEX(date_city!1:1,MATCH("Date of Sale",date_city!1:1,FALSE)),0,0,COUNTA(INDEX(date_city!1:65521,,MATCH("Date of Sale",date_city!1:1,FALSE))),1)) ">" & Criteria!$F$4)*(OFFSET(INDEX(date_city!1:1,MATCH("Date of Sale",date_city!1:1,FALSE)),0,0,COUNTA(INDEX(date_city!1:65521,,MATCH("Date of Sale",date_city!1:1,FALSE))),1)) "<" & Criteria!$G$4), OFFSET(INDEX(date_city!1:1,MATCH("Price Per SF",date_city!1:1,FALSE)),0,0,COUNTA(INDEX(date_city!1:65521,,MATCH("Price Per SF",date_city!1:1,FALSE))),1)
Thanks in advance for any help.
FormulaDesk can display your formula in a way that is very easy and quick to understand, rolling-up nested parts together with their results. It should also pinpoint exactly where the error is.
[Disclosure: I am the author of FormulaDesk]

Resources