I want to calculate Relative Strength Index that use the sum of 14 day of Gains.
I can use SUM function then drag down to the bottom, but I want it to expand infinitely (H16 to H).
Is there any way to use ARRAYFORMULA? or I must use appscript?
I try many things and can't figure the way out.
try:
=INDEX(IF(SEQUENCE(MATCH(9, 1/(G3:G<>"")))<16,,
MMULT(N(IFERROR(SPLIT(REGEXEXTRACT(" "&trim(FLATTEN(QUERY(TRANSPOSE(IF(
SEQUENCE(MATCH(9, 1/(G3:G<>"")))>=SEQUENCE(1, MATCH(9, 1/(G3:G<>""))),
TRANSPOSE(INDIRECT("G3:G"&MATCH(9, 1/(G:G<>"")))), )),,9^9))),
REPT(" -?\d+(?:\.\d+)?", 14)&"$"), " "))), SEQUENCE(14, 1, 1, 0))))
try:
=ARRAYFORMULA(IF(SEQUENCE(COUNTA(G3:G))<14,,
MMULT(IFERROR(VLOOKUP(ROW(G3:G)-SEQUENCE(1, 14, 0),
{ROW(G3:G), G3:G}, 2, )*1, 0), SEQUENCE(14, 1, 1, 0))))
Related
In the below spreadsheet, I am trying to find the item with the highest total sales across various hours.
I would like to easily extract the highest and lowest selling item names as well as their corresponding total sales. I need to be able to do this without creating a helper column as I cannot edit the table.
I know there's probably an easy way to do this but for the life of me I cannot figure it out!
Link to Sheet
B12:
=INDEX(SORT(SPLIT(FLATTEN(B2:G10&"×"&A2:A10&"×"&B1:G1), "×"), 1, 0), 1, 2)
B13:
=INDEX(SORT(SPLIT(FLATTEN(B2:G10&"×"&A2:A10&"×"&B1:G1), "×"), 1, 0), 1, 1)
B14:
=INDEX(SORT(SPLIT(FLATTEN(B2:G10&"×"&A2:A10&"×"&B1:G1), "×"), 1, 1), 1, 2)
B15:
=INDEX(SORT(SPLIT(FLATTEN(B2:G10&"×"&A2:A10&"×"&B1:G1), "×"), 1, 1), 1, 1)
** edit: use player0's for the overall min and max.
Check this demo sheet
To get the highest or lowest by time slot (put this in I5),
=ARRAYFORMULA(
IFERROR(
VLOOKUP(
TRANSPOSE(B1:G1),
SORT(
SPLIT(
FLATTEN(B1:G1&"|"&A2:A&"|"&B2:G),
"|"),
3,FALSE),
{1,2,3},FALSE)))
Then to align the lowest per timeslot with that, put this in M5
=ARRAYFORMULA(
IF(ISBLANK(I5:I),,
IFERROR(
VLOOKUP(
I5:I,
SORT(
SPLIT(
FLATTEN(B1:G1&"|"&A2:A&"|"&B2:G),
"|"),
3,FALSE),
{2,3},FALSE))))
If you also wanted conditional formatting for the daily high and low, use a range of B2:G with
=AND(LEN(B2),MIN($B2:$G2)=B2)
If you really want to have these formulas below the table, change
FLATTEN(B1:G1&"|"&A2:A&"|"&B2:G),
to
FLATTEN(B1:G1&"|"&A2:A10&"|"&B2:G10),
select sum(Col1),sum(Col2),sum(Col3) ... up to 500 columns but the number might increase or decrease... what is the best way to go about this with one formula?
it would be really nice if you could just do select sum(*) ... but sadly that does not seem to work.
you can do:
=ARRAYFORMULA(QUERY({A1:SF}, "select "&TEXTJOIN(",", 1, "sum(Col"&ROW(A1:A500)&")")))
or:
=ARRAYFORMULA(QUERY({A1:SF}, "select "&TEXTJOIN(",", 1, "sum(Col"&COLUMN(A1:SF)&")")))
or infinitely expanding:
=ARRAYFORMULA(QUERY({INDIRECT("A1:"&SUBSTITUTE(ADDRESS(1, COLUMNS(1:1), 4), 1, ))},
"select "&TEXTJOIN(",", 1, "sum(Col"&ROW(INDIRECT("A1:A"&COLUMNS(1:1)))&")")))
Looking for a more efficient way, possibly array formula for Min/Max down a column. Not sure if array formulas work with this function as I can't get it to.
=ArrayFormula(MAX(INDIRECT("Data!E"&(K42:K169)&":E"&(K43:K170-1))))
=ARRAYFORMULA(MAX(VLOOKUP(K42:K169, {ROW(Data!A:A), Data!E:E}, 2, 0)&VLOOKUP(K43:K170-1, {ROW(Data!A:A), Data!E:E}, 2, 0)))
Note that I am using ROW(Data!A:A) instead of simply ROW(A:A) because the range in current sheet doesn't fit that of sheet Data!.
Here is my current code copied down columns in my sheet.
=MAX(INDIRECT("Data!E"&(K42-1)&":E"&(K43-1)))
Just need a more efficient way. Am I correct that using INDIRECT results in slow calculation times.
=ARRAYFORMULA(QUERY(TRANSPOSE(QUERY(TRANSPOSE(QUERY(SPLIT(TRANSPOSE(SPLIT(QUERY(
INDIRECT("Data!E"&K42&":E"&MAX(K42:K))&","&IF(MOD(ROW(
INDIRECT("Data!A1:A"&COUNTA(L42:L)*K41)), K41)=0, "♦", ),,999^99), "♦")), ","),
"where Col2 is not null", 0)),
"select "&TEXTJOIN(",", 1, IF(LEN(L42:L),
"max(Col"&ROW(A42:A)-ROW(A42)+1&")", ))&"")),
"select Col2"))
How can I compare between A and E and If matches then put the difference in I?
=ARRAYFORMULA(IF(LEN(I4:I),
IFERROR(VLOOKUP(I4:I, E4:F, 2, 0))-
IFERROR(VLOOKUP(I4:I, A4:B, 2, 0)), ))
I have this formula for counting matches in Contents!$B$2 in J4.
=ARRAYFORMULA(IF(NOT(REGEXMATCH(J4,
"\w")),0,SUM(COUNTIF(REGEXREPLACE(SPLIT(J4,","),"
[\s]",""),REGEXREPLACE(SPLIT(Contents!$B$2,","),"[\s]","")))))
The formula is in K4 but ideally, I want it to work right down J returning values to the relevant adjacent K. I tried this but it didn't work. Just filled the cell the formula was in
=ARRAYFORMULA(IF(NOT(REGEXMATCH(J4:J,
"\w")),0,SUM(COUNTIF(REGEXREPLACE(SPLIT(J4:J,","),"
[\s]",""),REGEXREPLACE(SPLIT(Contents!$B$2,","),"[\s]","")))))
I know I can just fill down but the issue is users inserting rows.
Thanks in advance for any assistance
=ARRAYFORMULA(IF(LEN(A2:A), IFERROR(VLOOKUP(A2:A,
QUERY(TRIM(TRANSPOSE(SPLIT(Contents!B1, ","))),
"select Col1,count(Col1) group by Col1", 0), 2, 0), 0), ))