You can make a difference in the Apple Support Community!

When you sign up with your Apple Account, you can provide valuable feedback to other community members by upvoting helpful replies and User Tips.

Looks like no one’s replied in a while. To start the conversation again, simply ask a new question.

ABS formula not able to accept an Array

Hi Community,


The goal is to find if the time of day and reported shark numbers "No#" (in the Coral Bay WA Aus shark sanctuary) which coincide with the tide condition.

The key issues I have is there isn't always the same number of tides per day, so using a variable array via my indirect DateRow# and EndDateRow# is how I have tried to addressed this, but the array isn't possible within an ABS formula (as I have to find the closet tide +/- of the reported time (Table 1)).

  • I don't believe adding a helper column will work in this case as the tide actual time (Table 2::C) would have to be compared to every actual time (Table 1::B) which isn't possible to have that many helper rows (maybe I'm missing something :) ).

The rest of the formula is to allow me to identify if it's an Incoming or Outgoing High/Low etc tide.

  • I'm open for ideas for improvements but it's secondary to the above issue.


If anyone has some ideas or a totally different approach I would love to hear it.


The ABS part of the formula which is currently in Table 1::G2, always returns the first result as the array doesn't work. The formula used is below


MIN(ABS(C2−INDIRECT("Table 2::$D"&$E2&":$D"&$F2,addr-style)))


The full formula which is very, very long (sorry but just incase it helps) is.


=IF(XLOOKUP(INDEX(INDIRECT("Table 2::$D"&$E2&":$D"&$F2,addr-style),MATCH(MIN(ABS(C2−INDIRECT("Table 2::$D"&$E2&":$D"&$F2,addr-style))),ABS(C2−INDIRECT("Table 2::$D"&$E2&":$D"&$F2,addr-style)),1),column-index,area-index),INDIRECT("Table 2::$D"&$E2&":$D"&$F2,addr-style),Table 2::B2:B9,if-not-found,0,1)="HIGH",IF(C2−MIN(INDIRECT("Table 2::$D"&$E2&":$D"&$F2,addr-style))>Table 3::C2,Table 3::$A8,IF(C2−MIN(INDIRECT("Table 2::$D"&$E2&":$D"&$F2,addr-style))>Table 3::E2,Table 3::$A2,IF(C2−MIN(INDIRECT("Table 2::$D"&$E2&":$D"&$F2,addr-style))>0,Table 3::$A6,IF(C2−MIN(INDIRECT("Table 2::$D"&$E2&":$D"&$F2,addr-style))<Table 3::E3,Table 3::$A8,IF(C2−MIN(INDIRECT("Table 2::$D"&$E2&":$D"&$F2,addr-style))<Table 3::C3,Table 3::$A3,IF(C2−MIN(INDIRECT("Table 2::$D"&$E2&":$D"&$F2,addr-style))<0,Table 3::$A6,if-false)))))),IF(C2−MIN(INDIRECT("Table 2::$D"&$E2&":$D"&$F2,addr-style))>Table 3::C4,Table 3::$A8,IF(C2−MIN(INDIRECT("Table 2::$D"&$E2&":$D"&$F2,addr-style))>Table 3::E4,Table 3::$A4,IF(C2−MIN(INDIRECT("Table 2::$D"&$E2&":$D"&$F2,addr-style))>0,Table 3::$A7,IF(C2−MIN(INDIRECT("Table 2::$D"&$E2&":$D"&$F2,addr-style))<Table 3::C5,Table 3::$A7,IF(C2−MIN(INDIRECT("Table 2::$D"&$E2&":$D"&$F2,addr-style))<Table 3::E5,Table 3::$A5,IF(C2−MIN(INDIRECT("Table 2::$D"&$E2&":$D"&$F2,addr-style))<Table 3::E5,Table 3::$A8,"Issue with formula")))))))


Very much looking forward to any possible ideas on how to address this issue,


Thanks,

Stuart.


MacBook Air, macOS 14.6

Posted on Sep 18, 2024 11:11 PM

Reply
Question marked as Top-ranking reply

Posted on Sep 19, 2024 3:32 PM


Table 1:

C2 =INDEX(Table 3::A,I)

D2 =XLOOKUP(A2,Table 2::A,Table 2::A,"NF",−1)

E2 =XLOOKUP(A2,Table 2::A,Table 2::A,"NF",1)

F2 =IF(A2−D2≤E2−A2,D2,E2)

G2 =XLOOKUP(F2,Table 2::A,Table 2::B)

H2 =DUR2HOURS($A2−F2)

I2 =MINIFS(Table 3::E,Table 3::D,G,Table 3::B,"<="&H2,Table 3::C,">="&H2)

Fill down with all of them


Table 2 is all manually entered. Note that you will get an error in Table 1 if a siting is before the first tide or after the last tide in Table 2.


Table 3 is manually entered except for column E

E2 = ROW()

fill down


Hide columns D-I in Table 1

Hide column E in Table 3



5 replies
Question marked as Top-ranking reply

Sep 19, 2024 3:32 PM in response to stuart273


Table 1:

C2 =INDEX(Table 3::A,I)

D2 =XLOOKUP(A2,Table 2::A,Table 2::A,"NF",−1)

E2 =XLOOKUP(A2,Table 2::A,Table 2::A,"NF",1)

F2 =IF(A2−D2≤E2−A2,D2,E2)

G2 =XLOOKUP(F2,Table 2::A,Table 2::B)

H2 =DUR2HOURS($A2−F2)

I2 =MINIFS(Table 3::E,Table 3::D,G,Table 3::B,"<="&H2,Table 3::C,">="&H2)

Fill down with all of them


Table 2 is all manually entered. Note that you will get an error in Table 1 if a siting is before the first tide or after the last tide in Table 2.


Table 3 is manually entered except for column E

E2 = ROW()

fill down


Hide columns D-I in Table 1

Hide column E in Table 3



Sep 19, 2024 6:21 AM in response to stuart273

That is way too complicated. If anything changes in your table and you need to edit that formula it will be a royal pain. If something doesn't work right it will be very difficult to debug. Here are some thoughts:


First I have a question about your formula which might negate/change what I write below. You are limiting the range of your ABS to tides that occur on the same day but tides are a continuous thing and your shark siting might be closer to a tide on the next or previous day. Your formula doesn't look at those tides and, to me, it will give wrong results. What I am suggesting below uses the date & time as continuous and looks in Table 2 for the closest date & time. It may return a value from the day before or the day after.


  1. Make Table 1 column A the date & time of each siting and delete columns B and C. You also won't need columns E or F so you can delete them, too
  2. Make Table 2 column A the date & time of each tide, delete column D, and remove the time from column C. Use column C only for the depth. All the info for each tide will fit on a single row; it will not require two rows per tide. All data for a tide must be in one row. Every row needs a date & time in column A.
  3. With those two changes you can use XLOOKUP to look up what the closest tide was without having to use INDIRECT at all. In one column you will look for a date & time in Table 2::A that is "exact or next smallest" to your siting and return that date & time. In another you will look for a date&time that is "exact or next highest" and return that date & time. I'll call those two columns J and K for now
  4. With those two, you can do some simple math to determine which is closest and that will determine which of those date&times you use for any other lookups. =IF(A-J<=K-A,XLOOKUP(J,Table 2::A,Table 2::B),XLOOKUP(K,Table 2::A, Table 2::B)) will give you whether it was closer to low or high tide.


That's the general idea. I don't understand your Table 3 and I'm not going to even try deciphering your long formula so I'll stop here. Most of this requires extra columns to do the work piece by piece rather than trying to force everything into an extremely long formula.

Sep 19, 2024 9:49 PM in response to Badunit

Hi Badunit,


Thanks for all your work compiling this and making it work, amazing the difference it makes simplifying things by keeping the full date and time (removing the indirect's) and adding the extra columns as needed.


Amazing work and extremely helpful.


We have received several signings of shark pup's (baby's) which will be shortly added to the numbers document.


Thanks once again.


Stuart.

ABS formula not able to accept an Array

Welcome to Apple Support Community
A forum where Apple customers help each other with their products. Get started with your Apple Account.