Reversing ArrayFormula Results - google-sheets

I have an ArrayFormula which is taking a list of dates and times in text format from Col A, and creating true dates/times in Col B:
=arrayformula(
regexreplace(A2:A, "^([\w, ]+) at ([\w: ]+)$", "$1 $2")
)
Trying to figure out how to reverse the order of the results, so the most recent date is at the top of the list, but maxing out my formula knowledge and not finding anything as I Google around.
Appreciate any help!

Related

Inconsistent results when using arrayformula within Googlesheets

I have a formula that will calculate the working hours between two dates.
It works perfectly well when referring a few lines and ranges. As the data in this sheet is going to be automatically added to over time I wanted to use arrayformula to automatically calculate the duration for these new rows.
However when used within arrayforumla the values are unpredictably different.
I can't make any sense of why it's different.
Below is an example;
https://docs.google.com/spreadsheets/d/1cWZwpnkp2MPyM-EppjOYHRcMEcblscU70R62uf691Xw/edit#gid=0
Any suggestions as to why the formula is behaving differently would be greatly appreciated!
Edit
For posterity;
Formula that worked when inline (COL C);
=TEXT((NETWORKDAYS.INTL(A2,B2,1,F$7:F$9)-1)*($G$2-$F$2)+IF(NETWORKDAYS.INTL(B2,B2,1,F$7:F$9),MEDIAN(MOD(B2,1),$F$2,$G$2),$G$2)-MEDIAN(NETWORKDAYS.INTL(A2,A2,1,F$7:F$9)*MOD(A2,1),$F$2,$G$2),"[hh]:mm:ss")
Forumla that didn't work in arrayformula (COL D);
=ARRAYFORMULA(
IF(ROW(B:B)=1, "Array Formula Duration",
IF(ISBLANK(B:B),"",
(NETWORKDAYS.INTL(A2:A,B2:B,1,F$7:F$9)-1)*($G$2-$F$2)+IF(NETWORKDAYS.INTL(B2:B,B2:B,1,F$7:F$9),MEDIAN(MOD(B2:B,1),$F$2,$G$2),$G$2)-MEDIAN(NETWORKDAYS.INTL(A2:A,A2:A,1,F$7:F$9)*MOD(A2:A,1),$F$2,$G$2)
)
)
)
Forumla that sorted it (COL E);
={"Array Formula Duration";map(A2:A,B2:B,lambda(a,b,if(b="",,TEXT((NETWORKDAYS.INTL(a,b,1,F7:F9)-1)*(G2-F2)+IF(NETWORKDAYS.INTL(b,b,1,F7:F9),MEDIAN(MOD(b,1),F2,G2),G2)-MEDIAN(NETWORKDAYS.INTL(a,a,1,F7:F9)*MOD(a,1),F2,G2),"[hh]:mm:ss"))))}
You may try:
={"Array Formula Duration";map(A2:A,B2:B,lambda(a,b,if(b="",,TEXT((NETWORKDAYS.INTL(a,b,1,F7:F9)-1)*(G2-F2)+IF(NETWORKDAYS.INTL(b,b,1,F7:F9),MEDIAN(MOD(b,1),F2,G2),G2)-MEDIAN(NETWORKDAYS.INTL(a,a,1,F7:F9)*MOD(a,1),F2,G2),"[hh]:mm:ss"))))}

Google Sheets: Cell formula NOT working in ARRAYFORMULA

I've a regularly updating sheet of daily foreign exchange rates (descending order sorted).
I've written a cell formula, which works fine if I drag it to the end.
=IFNA( VLOOKUP(A2,USD_TRY!$A$2:$B$3289,2,FALSE), INDEX(USD_TRY!$A$2:$C$3289, MATCH(A2,USD_TRY!$A$2:$A$3289,-1), 3 ) )
Column A2:A is daily dates, merged from 2 different sheets of daily rates and different currencies (so it skips some dates) but it has more dates than the column USD_TRY!A2:A. This formula gets the Price rate from column USD_TRY!B2:B if the VLOOKUP() date matches but if it doesn't match then it gets the Open rate from column USD_TRY!C2:C a row before (a day after) the closest match. However, if I convert the same formula to ARRAYFORMULA() then the VLOOKUP() part works fine but the INDEX(MATCH()) part gives a wrong result of USD_TRY!C2 every time.
IF(
AND(NOT(ISBLANK(A2:A)), NOT(ISBLANK('USD_TRY Historical Data'!A2:A)), NOT(ISBLANK('USD_TRY Historical Data'!B2:B)), NOT(ISBLANK('USD_TRY Historical Data'!C2:C)) ),
ARRAYFORMULA(
IFNA(
VLOOKUP(A2:A,'USD_TRY Historical Data'!A2:B,2,FALSE),
INDEX('USD_TRY Historical Data'!A2:C, MATCH(A2:A,'USD_TRY Historical Data'!A2:A,-1), 3 ) )
)
)
}
How do I correct the ARRAYFORMULA() and is there any simpler way to get the correct results as array?
Source data:
Correct output (with cell formula):
Wrong result (with array formula):
try:
=ARRAYFORMULA(IFNA(
VLOOKUP(A2:A4, E2:F6, 2, 0),
VLOOKUP(90000-A2:A4, {90000-E2:E6, G2:G6}, 2, 1)))

How to use 1 formula to Count items by date?

https://docs.google.com/spreadsheets/d/1_b-wdVQFKKSpJtNF4coNhQvmv20mUFSGkpppbOTE9Cg/edit?usp=sharing
Hi, I am trying to build a report. How can I write 1 formula at B2 to count the SKUs by date? Thank you so much for your help.
See my added sheet ("Erik Help"). The formula in B2:
=ArrayFormula(IFERROR(VLOOKUP(FILTER(A2:A,A2:A<>"")&"~"&FILTER(B1:1,B1:1<>""),QUERY({Data!D2:D&"~"&Data!A2:A},"Select Col1, COUNT(Col1) GROUP BY Col1"),2,FALSE)))
The FILTERs aren't strictly necessary, but they will speed up processing, especially if you have a lot of data in your real sheet.
Every element from A2:A (the SKUs) is concatenated with a tilde ~ and then every element of B1:1 (the dates).
QUERY forms a two-column grouping of each SKU~date and COUNT of each from the Data sheet.
VLOOKUP then acts on every element of the virtual array grid, trying to find it within the QUERY. If found, the COUNT is returned. If not, IFERROR returns null.

Google Sheets limit on function

I have formula that I've been using for a while however the formula doesn't work properly anymore.
This is the formula:
=ArrayFormula(INDEX(FILTER(C3:HG3,(C2:HG2="keyword")*(C3:HG3<>"")),1,COUNTIFS(C2:HG2,"keyword",C3:HG3,"<>")))
From time to time I expend the columns and populate them with data.
I started using the formula somewhere from column FX now to column HG and I would like to expend it to column HJ but the formula doesn't work anymore. Is there a limit on calculations on formula's in Google sheets?
try:
=INDEX(INDEX(FILTER(C3:HJ3, (C2:HJ2="keyword")*(C3:HJ3<>"")), 1,
COUNTIFS(C2:HJ2, "keyword", C3:HJ3, "<>")))

google sheet formula : vlookup across multiple columns not working

this is my spreadsheet
on first sheet 'consolidation' column O
I want to get the date value by
finding the number from 'articles' sheet [column H to AJ] [articles!H:AJ]
that match with the value in column M of 'consolidation'
then return the date from column F [articles!F:F]
so on cell O6 I put in this formula
=VLOOKUP(M6,articles!F:AJ,{1},0)
{1} is column F that I want to return
[it has multiple results but I think vlookup will return the first one that it found which is fine cause it sorted by date]
but the problem is it's not finding anything on 'articles' range F:AJ
I don't know why
this might be the stupid way to do
anyone know please give me an advice, thanks
Try
=ARRAYFORMULA(TEXTJOIN(",",1,IF(REGEXMATCH(","&articles!B:B,","&M6&","),TEXT(articles!F:F,"mm/dd/yyyy"),)))
REGEX to match M6 to anything between the ,
IF to find the date
JOIN to join the found dates

Resources