+ Reply to Thread
Results 1 to 12 of 12

Array formula needs a condition added to it

  1. #1
    Registered User
    Join Date
    09-22-2020
    Location
    Wales, UK
    MS-Off Ver
    O365
    Posts
    6

    Question Array formula needs a condition added to it

    Hi there, thanks for clicking.

    Preamble

    I used to be a bit of a power user with Excel, although somehow I don't remember needing to create an array formula until now. And what's worse is I've been in a new job for a few years and don't remember a lot of the Excel skills I used to have!

    The problem

    I've replicated an array formula that works great. I can't post links because I'm new otherwise I'd reference where I got it from but I guess that doesn't matter. It's a formula to list some rows of data on a dashboard sheet where the date row is between specific dates.

    But I also need to add something to the array, so as well as coping with specific dates, it only returns rows that meet another condition. In this case, only if the row's column titled 'Target' matches the Target value on the dashboard sheet should it return the row.

    I tried inserting an IF function into the array, and it kinda works; it indeed will only return rows that meet the 'Target' condition. However, I clearly don't know what I'm doing because instead of a tidy array without gaps, my IF function would result in row gaps because it's not very clever. (I've removed the IF function from the attached). I can understand why it does this, just about, but not how to overcome it.

    So I'm hoping some Excel guru could please take a look at this and let me know how to amend the array formula on the dashboard so it doesn't lose its current functionality but also only returns rows that match the 'Target' value. I hope this is clear.

    Thank you!
    Attached Files Attached Files

  2. #2
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Array formula needs a condition added to it

    Have you considered a simple Pivot Table and a Slicer or three to help with filtering it. This will avoid Excel functions altogether
    Richard Buttrey

    RIP - d. 06/10/2022

    If any of the responses have helped then please consider rating them by clicking the small star icon below the post.

  3. #3
    Registered User
    Join Date
    09-22-2020
    Location
    Wales, UK
    MS-Off Ver
    O365
    Posts
    6
    Thanks for replying Richard. For my needs that won't be sufficient (I stripped the attachment down but the actual spreadsheet is more complex).

    I'm confident this can be achieved with an amendment to the existing formula. After all, it already does the requirement with one condition (date range); I'm just looking at something to extend this to an additional condition.

    Although admittedly I don't know how to do it!

  4. #4
    Forum Moderator - RIP Richard Buttrey's Avatar
    Join Date
    01-14-2008
    Location
    Stockton Heath, Cheshire, UK
    MS-Off Ver
    Office 365, Excel for Windows 2010 & Excel for Mac
    Posts
    29,464

    Re: Array formula needs a condition added to it

    Hi,

    As you say this is clearly a much simplified example and doesn't represent the size of your actual data. We often find that when we give an answer to what is a trivial non representative example when the solution is used with the real world data it doesn't work because of factors like string length and other stuff which is important but hasn't been mentioned. It's why we always prefer to see the production workbook itself.

    Therefore upload your real workbook (or at least a cut down but truly representative copy), and manually add the results you expect to see. Clearly identify which is original data and which are the results and in a note clearly explain how you have arrived at your results.

  5. #5
    Forum Expert
    Join Date
    07-20-2011
    Location
    Mysore, India.
    MS-Off Ver
    Excel 2019
    Posts
    8,577

    Re: Array formula needs a condition added to it

    Try this
    ARRAY formula in A4 and copied across.
    Please Login or Register  to view this content.
    Attached Files Attached Files
    Pl note
    Array formula should be confirmed with Ctrl+Shift+Enter keys together.
    If answere is satisfactory press * to add reputation.

  6. #6
    Registered User
    Join Date
    09-22-2020
    Location
    Wales, UK
    MS-Off Ver
    O365
    Posts
    6

    Re: Array formula needs a condition added to it

    Edit: Ignore, just reviewing the latest reply!
    Last edited by ReturningHack; 09-23-2020 at 08:55 AM. Reason: Missed the most recent reply

  7. #7
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,068

    Re: Array formula needs a condition added to it

    If you have the filter function
    =FILTER(Data!A2:C10,(Data!A2:A10>=A2)*(Data!A2:A10<=B2)*(Data!C2:C10=D2))

  8. #8
    Registered User
    Join Date
    09-22-2020
    Location
    Wales, UK
    MS-Off Ver
    O365
    Posts
    6

    Re: Array formula needs a condition added to it

    Hi kvsrinivasamurthy,

    Thanks for the attempt. It doesn't quite work; it works correctly if the Target value in D2 is 'All', but if the Target value in D2 is 'Some' then the array doesn't differentiate and returns rows with either Target value. I've ensured the formula is entered as an array.

    ***

    And hi Fluff13, sadly my current version of O365 doesn't have the =FILTER function.

  9. #9
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,068

    Re: Array formula needs a condition added to it

    Ok, how about
    =IFERROR(INDEX(Data!A$2:A$22,AGGREGATE(15,6,(ROW(Data!$A$2:$A$22)-ROW(Data!$A$2)+1)/(Data!$A$2:$A$22>=$A$2)/(Data!$A$2:$A$22<=$B$2)/(Data!$C$2:$C$22=$D$2),ROWS(A$5:A5))),"")

  10. #10
    Registered User
    Join Date
    09-22-2020
    Location
    Wales, UK
    MS-Off Ver
    O365
    Posts
    6

    Re: Array formula needs a condition added to it

    Quote Originally Posted by Fluff13 View Post
    Ok, how about
    =IFERROR(INDEX(Data!A$2:A$22,AGGREGATE(15,6,(ROW(Data!$A$2:$A$22)-ROW(Data!$A$2)+1)/(Data!$A$2:$A$22>=$A$2)/(Data!$A$2:$A$22<=$B$2)/(Data!$C$2:$C$22=$D$2),ROWS(A$5:A5))),"")
    This is it!! Thank you Fluff13.

    Thanks everyone who helped.

  11. #11
    Forum Guru
    Join Date
    09-10-2017
    Location
    Chippenham, England
    MS-Off Ver
    365
    Posts
    15,068

    Re: Array formula needs a condition added to it

    Glad to help & thanks for the feedback.

  12. #12
    Registered User
    Join Date
    09-22-2020
    Location
    Wales, UK
    MS-Off Ver
    O365
    Posts
    6

    Re: Array formula needs a condition added to it

    It's the least I could do. I work for a cash-strapped public service organisation, and the file this will be used for will help several people.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Array formula fails when additional column of data added
    By sipa in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-19-2020, 06:40 PM
  2. Added to an IF/AND array formula
    By Motox in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 05-22-2019, 12:30 AM
  3. [SOLVED] Need To Add Addition Condition In Array Formula
    By warriorpoet7176 in forum Excel Formulas & Functions
    Replies: 7
    Last Post: 07-08-2016, 07:02 PM
  4. [SOLVED] Multiple if Condition and array formula
    By Formula-seeker in forum Excel General
    Replies: 4
    Last Post: 06-09-2015, 10:02 AM
  5. [SOLVED] Way to have Array Formula automatically adjust when rows added
    By bdouglas1011 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 09-28-2014, 04:00 PM
  6. [SOLVED] Array formula not expanding to match lines added to table
    By justmatt in forum Excel General
    Replies: 13
    Last Post: 05-03-2014, 02:16 PM
  7. Replies: 8
    Last Post: 05-08-2013, 11:47 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1