Adapt a formula to ArrayFormula - google-sheets

Im very new to Google Sheets formulas.
Im trying to convert this formula:
=INDEX(PRX_ARM,MATCH(ELECTRICITE!E97,OFFSET(PRX_ARM_C1,0,MATCH(ELECTRICITE!G97,PRX_ARM_L1
,1)-1),1), MATCH(ELECTRICITE!G97&"1",PRX_ARM_L1,1))+
ELECTRICITE!H97*INDEX(PRX_REL,2,2)+
ELECTRICITE!I97*INDEX(PRX_REL,3,2)+
ELECTRICITE!J97*INDEX(PRX_BP_VOY,2,2)+
ELECTRICITE!K97*INDEX(PRX_BP_VOY,3,2)+
ELECTRICITE!L97*INDEX(PRX_BP_VOY,4,2)+
ELECTRICITE!M97*INDEX(PRX_BP_VOY,5,2)
So naturally, i converted every single cell reference to the range ArrayFormula must be applied to :
=ArrayFormula(INDEX(PRX_ARM,MATCH(ELECTRICITE!E90:E5030,OFFSET(PRX_ARM_C1,0,MATCH(ELECTRICITE!G90:G5030,PRX_ARM_L1,1)-1),1),
MATCH(ELECTRICITE!G90&"1",PRX_ARM_L1,1))+
ELECTRICITE!H90:H5030*INDEX(PRX_REL,2,2)+
ELECTRICITE!I90:I5030*INDEX(PRX_REL,3,2)+
ELECTRICITE!J90:J5030*INDEX(PRX_BP_VOY,2,2)+
ELECTRICITE!K90:K5030*INDEX(PRX_BP_VOY,3,2)+
ELECTRICITE!L90:L5030*INDEX(PRX_BP_VOY,4,2)+
ELECTRICITE!M90:M5030*INDEX(PRX_BP_VOY,5,2))
But it does not work.
Do you know what im doing wrong?
Thanks in advance.

Yu can't use index with arrayformula, use instead vlookup

Related

How to use COUNTIFS with ARRAYFORMULA

I have this formula that checks for the 2nd(onwards) instance of duplicate using 2 columns. I want it to be automatically applied to new rows but can't seem to figure out how to use ARRAYFORMULA for COUNTIFS. Can anybody please help me convert this formula =COUNTIFS($K$2:$K2, $K2, $T$2:$T2, $T2)>1 to an arrayformula or something similar? Thanks!
MAP() function may be a good solution. Try-
=MAP($K$2:INDEX($K$2:$K,COUNTA($K$2:$K)),$T$2:INDEX($T$2:$T,COUNTA($K$2:$K)),LAMBDA(x,y,COUNTIFS($K$2:$K,x,$T$2:$T,y)>1))
K2:INDEX(K2:K,COUNTA(K2:K)) will return a array of range from K2 to next non empty cell of K column.
Same T2:INDEX(T2:T,COUNTA(K2:K)) will return a array of range from T column still base on K column last non empty cell.
Edit: As per comment, try below formula-
=INDEX(MAP(A2:INDEX(A2:A,COUNTA(A2:A)),C2:INDEX(C2:C,COUNTA(A2:A)),LAMBDA(x,y,COUNTIFS(A2:A,x,C2:C,y,ROW(A2:A),"<="&ROW(x))>1)))
Change ranges for your sheet.

Extract Substrings using importxml in google sheets

Using IMPORTXML in google sheets. I want to extract part of the result into one cell.
=IMPORTXML(B1,"//div[#class='orca-rating SwtJyda color-yellow tbody-6']/span")
I got the result spread over several columns. B8:F8
The inspect element is like this. I only want the value "2". It is in cell B8.
I think this can be done using substring-after. But I could not get the correct result.
In your situation, how about the following samples?
=REGEXREPLACE(JOIN("",IMPORTXML(B1,"//div[#class='orca-rating SwtJyda color-yellow tbody-6']/span")),"[^0-9]","")
=REGEXEXTRACT(JOIN("",IMPORTXML(B1,"//div[#class='orca-rating SwtJyda color-yellow tbody-6']/span")),"\((.*)\)")
References:
REGEXREPLACE
REGEXEXTRACT
I use this formula. That works too.
=INDEX( IMPORTXML(B1,"//div[#class='orca-rating SwtJyda color-yellow tbody-6']/span"),3)
But tanaike's formula is very good.

Problem with Array Formula and Concatenate

I'm trying to build an array formula on google sheets for this :
=CONCATENATE(MID(C2,4,3),(MID(C2,1,3)),MID(C2,7,4))
The problem is that when I use array formula going from C2:C, it will concatenate all the rows at the same time, which is not what I want.
Does anybody know how to properly use the array on that case? So it will keep looking for just the value on C2, C3,C4 and so on?
Thank you!
Use the ampersand character instead of CONCATENATE:
=ArrayFormula(IF(C2:C="", "", MID(C2:C,4,3)&(MID(C2:C,1,3))&MID(C2:C,7,4)))

Google Spreadsheet, use array formula with filter betwen date

Hy everyone,
I try a simple trick, Use an array formula with a countblank with a filter between date. Without array, its work great, with an array, it goes crazy. why?
I use a spreadsheet to follow the present or absent off people by month. (exemple sheet)
I try to like this by line and its work fine:
=COUNTBLANK(FILTER(D9:AU9,D8:AU8>=B4,D8:AU8<=B5))
When i try to apply this to every line, its goes crazy :
=ARRAYFORMULA(IF(A8:A19<>"",COUNTBLANK(FILTER(D8:AU,D8:AU8>=B4,D8:AU8<=B5)),""))
Where is my mistake?
In C8 try this formula
={""; Arrayformula( if(len(A9:A), countif(if((D9:AU="")*(month($D$8:$8)=month($B$3)), row(A9:A)), row(A9:A)),))}
and see if that works?

This array formula is not working

Hi following formula is working, but array formula is not working.
Working EQ:
=IF(V2:V=1,INDEX($E$2:$E,MATCH(T2&B2&"Delivered Time (Today)",$T$2:$T&$B$2:$B&$C$2:$C,0)),"")
I wonder, but this formula is not working:
=ARRAYFORMULA(IF(V2:V=1,INDEX($E$2:$E,MATCH(T2&B2&"Delivered Time (Today)",$T$2:$T&$B$2:$B&$C$2:$C,0)),""))
Can someone educate me to fix this?
Example details:
Example Sheet is here
Unfortunately not all Sheets functions work within an arrayformula, and INDEX and MATCH are two that do not
Instead, you can use VLOOKUP and construct an array to do the job of INDEX/MATCH:
=ArrayFormula(IF(V2:V=1,VLOOKUP(T2:T&B2:B&"Delivered Time (Today)",{T2:T&B2:B&C2:C,E2:E},2,0),))
You can it working in this copy of your example sheet:
https://docs.google.com/spreadsheets/d/1dFVNfPn0R9goQaLjRvZEwggRthbkEY3nC3aqC2joPcw/edit?usp=sharing

Resources