+ Reply to Thread
Results 1 to 21 of 21

Formula to filter results from data

  1. #1
    Forum Contributor
    Join Date
    08-21-2014
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    232

    Question Formula to filter results from data

    Hi all,

    Tricky one for me this - bit of logic help with an index/match coupled with IF and AND commands.

    In the attached sheet, the YEAR tab contains a record of emails used in a campaign. The same email will be sent to different types of customers - columns L-O are where these differ.

    The OVERVIEW tab needs to pull in info from YEAR but ONLY for the main send of an email (column H), not the REMAIL.

    In cells A2 thru K2 of the OVERVIEW tab, I can find the data by keying to the EMAIL ID.

    But, in cell L2 I am trying to say;

    - using the same find criteria as columns B-K...
    - check if the cell contents of YEAR column L are the same as the adjacent row in YEAR column L
    - if so, return that value
    - if different, return the value below

    ... and am getting tied up in knots as the formula gets so long, and the number of parenthesis needed gets muddled.

    Ideally, I want to;
    - still do this IN formula
    - be able to use the same for columns to right of L by dragging along

    Can anyone look at what I've tried and suggest a solution please, or steer me where I've gone wrong?

    Thanks in advance,

    Ian
    Attached Files Attached Files

  2. #2
    Forum Expert
    Join Date
    12-03-2009
    Location
    Florence, Italy
    MS-Off Ver
    Excel 2019
    Posts
    1,796

    Re: Formula to filter results from data

    Hi

    in A2 to be copied across

    Please Login or Register  to view this content.
    The red segment is the filter, if you'd need add a new filter (example: from column F "wednesday")

    Please Login or Register  to view this content.
    And so on
    Last edited by canapone; 04-10-2017 at 08:30 AM. Reason: ...some cosmetics
    -----------------------------------------------------

    At Excelforum, you can say "Thank you!" by clicking the star icon ("Add Reputation") below the post.

    Please, mark your thread [SOLVED] if you received your answer.

  3. #3
    Forum Guru Pete_UK's Avatar
    Join Date
    12-31-2011
    Location
    Warrington, England
    MS-Off Ver
    Office 2019 (still learning)
    Posts
    24,704

    Re: Formula to filter results from data

    I'm not sure that I follow your requirements exactly, but I would do it this way:

    Put this formula in T2 of the YEAR sheet:

    =IF(H2="Main",MAX(T$1:T1)+1,"-")

    then copy down as far as you like in order to accommodate more data being added. This formula will generate unique sequential numbers for those records which match your criteria (i.e. column H is "Main").

    Put this formula in T2 of the Overview sheet:

    =IFERROR(MATCH(ROWS($1:1),YEAR!T:T,0),"")

    and copy this down. This will return the row where the sequential numbers occur on the YEAR sheet. You can hide the two columns T if you want the file to look the same as before.

    Then you can use this formula in A2 of the Overview sheet:

    =IF($T2="","",INDEX(YEAR!A:A,$T2))

    and this can be copied across and down to generate your table automatically. You might like to change the formula in N2 to this:

    =IF($T2="","",INDEX(YEAR!N:N,$T2)&"")

    so that it generates a blank rather than zero if the corresponding field in the YEAR sheet is blank. You can do this to O2 also.

    I've attached a file showing this.

    Hope this helps.

    Pete
    Attached Files Attached Files

  4. #4
    Forum Contributor
    Join Date
    08-21-2014
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    232

    Re: Formula to filter results from data

    @canapone - your solution seems to do the job, except that when I add and drag, column J of OVERVIEW is blank, where it should say TACTICAL.

    Unsure I understand what it's doing to find the data given that the formula isn't using the email id in column A as the lookup value to find the row? It's likely that, the OVERVIEW sheet will be on row 400 (for example) looking at a new YEAR sheet for that year -so it won't always follow that row 2 on one is looking for row 2 on the other, if that makes sense.

  5. #5
    Forum Expert
    Join Date
    12-03-2009
    Location
    Florence, Italy
    MS-Off Ver
    Excel 2019
    Posts
    1,796

    Re: Formula to filter results from data

    Hi Iantrix

    in sheet Overview, formulas don' t match "TYPE?" (cell J1) with J1 "TYPE" in sheet Year.

    Formula must match same headers.

    Hope it helps

  6. #6
    Forum Contributor
    Join Date
    08-21-2014
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    232

    Re: Formula to filter results from data

    @canapone - yes, it helps and also helps me understand a little of what the formula is doing - have attached the sheet again with some numbers.

    In columns P,Q and R I want to then retrieve numbers relevant to the EMAIL ID and also relevant to the contents of columns L, M, N and O - and there are 3 scenarios;

    - retrieve number for MAIN in column H of YEAR
    - retrieve number for REMAIL in column H of YEAR
    - sum numbers for MAIN and REMAIL in column H of YEAR

    How would I adapt that formula solution to do each of these, or do I need a different formula? Is it a case of changing the AGGREGATE function?

    AND when applied to my real data, all seems fine except it's not ordering by DATE but my numerical JOB NO or EMAIL ID - is that simply a case of reordering columns OR filtering - will that break the formula solution?

    Thanks,

    Ian
    Attached Files Attached Files
    Last edited by iantix; 04-11-2017 at 06:37 AM. Reason: added query

  7. #7
    Forum Contributor
    Join Date
    08-21-2014
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    232

    Re: Formula to filter results from data

    @canapone

    Have found another issue when applied to my live data.

    The attached has 9 'MAIN' sends under jobno 02349-02 yet the OVERVIEW sheet is only 'seeing' 4 of them. Why is this please? Although the majority of the data for each of the 9 emails is the same, it differs when it comes to M, N and O columns where the same email is sent to different people.

    Also, how would I stop a 0 appearing where segment ID is blank (columns M,N and O of the OVERVIEW).

    Thanks,

    Ian
    Attached Files Attached Files

  8. #8
    Forum Expert
    Join Date
    05-05-2015
    Location
    UK
    MS-Off Ver
    Microsoft Excel for Microsoft 365 MSO (Version 2402 Build 16.0.17328.20068) 64-bit
    Posts
    28,147

    Re: Formula to filter results from data

    The reason is that for the missing data "Main" is actual "Main " i.e trailing blank.

    To "hide" zeros CUSTOM format as 0;;;@

  9. #9
    Forum Contributor
    Join Date
    08-21-2014
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    232

    Re: Formula to filter results from data

    @JohnTopley - you're a true gent - thanks for spotting - have cleaned my live data of those erroneous blanks

    Will try that hide solution...

  10. #10
    Forum Contributor
    Join Date
    08-21-2014
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    232

    Re: Formula to filter results from data

    @JohnTopley - formatting worked a treat, thanks

    @canapone - let me know if you've any suggestions please for post #6 above?

  11. #11
    Forum Contributor
    Join Date
    08-21-2014
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    232

    Re: Formula to filter results from data

    Have managed to sort all except summing data in MAIN and REMAIL rows for same email (based on status of columns L-O).

    Have attempted changing AGGREGATE to SUM (9) and added a filter - both on the yellow highlighted column R of OVERVIEW tab - can anyone assist with making this formula work please?

    Where am I going wrong?

    Thanks,

    Ian
    Attached Files Attached Files

  12. #12
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,414

    Re: Formula to filter results from data

    Tell us your expected outcomes in that yellow column, please.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  13. #13
    Forum Contributor
    Join Date
    08-21-2014
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    232

    Re: Formula to filter results from data

    No problem, sheet attached with an extra EXPECTED which has sums in to illustrate.

    Last row is a wildcard - if there is no second REMAIL number, formula should still just collate MAIN data for that column.

    Thank you,

    Ian
    Attached Files Attached Files

  14. #14
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,414

    Re: Formula to filter results from data

    That's what I thought they'd be!

    So try this, please:

    =IFERROR(INDEX(YEAR!$A$1:$R$103,AGGREGATE(15,6,ROW($1:$103)/--SUMPRODUCT((YEAR!$H$1:$H$103="main")+(YEAR!$H$1:$H$103="remail")),ROWS($1:1)),MATCH(R$1,YEAR!$A$1:$R$1,0)),"")

  15. #15
    Forum Contributor
    Join Date
    08-21-2014
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    232

    Re: Formula to filter results from data

    Thanks - have implemented - attached - but it's only seeing first value for the MAIN status in column H of year, not adding (for example);

    - where these values match on MAIN and REMAIL of that JOB NO;

    RECIPIENT INTEREST
    Model2 & Model7 P2
    SEGMENT ID 1
    Model2
    SEGMENT ID 2
    Users

    - should be finding value 33 from MAIN on row 2 of YEAR (cell R2) and value 102 from row 11 of YEAR (cell R11)
    - and adding them together
    Attached Files Attached Files

  16. #16
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,414

    Re: Formula to filter results from data

    OK - in over my head now, sorry.

  17. #17
    Forum Contributor
    Join Date
    08-21-2014
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    232

    Re: Formula to filter results from data

    Thanks for trying - am THIS close to nailing this sheet build, just need that last part to work.

    Hoping canapone will see and jump in as his initial solution was quite lovely

  18. #18
    Forum Expert
    Join Date
    12-03-2009
    Location
    Florence, Italy
    MS-Off Ver
    Excel 2019
    Posts
    1,796

    Re: Formula to filter results from data

    Hi All,

    on the last file you've shared I'm reading sheet overview column R.

    This formula in R2 return same output I see in S2

    Please Login or Register  to view this content.
    I'm not sure to have understood your needs.

    Please refer to the attachment,

  19. #19
    Forum Contributor
    Join Date
    08-21-2014
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    232

    Re: Formula to filter results from data

    Thanks - on the one I shared, formula in OVERVIEW cell R2 was;

    =IFERROR(INDEX(YEAR!$A$1:$R$103,AGGREGATE(15,6,ROW($1:$103)/--SUMPRODUCT((YEAR!$H$1:$H$103="main")+(YEAR!$H$1:$H$103="remail")),ROWS($1:1)),MATCH(R$1,YEAR!$A$1:$R$1,0)),"")

    Unsure how it returned correct value for you, for me it still shows '33'

    BUT your sheet with the much longer formula in OVERVIEW cell R2;

    =IFERROR(INDEX(YEAR!$R$1:$R$20,AGGREGATE(15,6,ROW($1:$20)/((YEAR!$M$1:$M$20=M2)*(YEAR!$H$1:$H$20="main")),COUNTIF($M$2:M2,M2))),0)+IFERROR(INDEX(YEAR!$R$1:$R$20,AGGREGATE(15,6,ROW($1:$20)/((YEAR!$M$1:$M$20=M2)*(YEAR!$H$1:$H$20="remail")),COUNTIF($M$2:M2,M2))),0)

    Works - but I am lost as to why/how.

    Have you repeated the formula by doing it twice & adding the result?

    THANK YOU for coming back to me however.

    Ian

  20. #20
    Forum Expert
    Join Date
    12-03-2009
    Location
    Florence, Italy
    MS-Off Ver
    Excel 2019
    Posts
    1,796

    Re: Formula to filter results from data

    Hi

    try to split in two column the formula

    =IFERROR(INDEX(YEAR!$R$1:$R$20,AGGREGATE(15,6,ROW($1:$20)/((YEAR!$M$1:$M$20=M2)*(YEAR!$H$1:$H$20="main")),COUNTIF($M$2:M2,M2))),0)

    =IFERROR(INDEX(YEAR!$R$1:$R$20,AGGREGATE(15,6,ROW($1:$20)/((YEAR!$M$1:$M$20=M2)*(YEAR!$H$1:$H$20="remail")),COUNTIF($M$2:M2,M2))),0)

    The two segments seek two discriminants to match 1)the model in M2, M3...2) "main" or "remail" in column H

    COUNTIF($M$2:M2) chooses the first/second/third smallest number row related to M2 and to main/remail. The first Model2/ main and remail, the second Model2/mail and remail.

    You're working more or less with a INDEX(SMALL...(IF...

    Maybe there are easier solutions to get same outputs.

    Forgive poor explanation (and even poorer English)

  21. #21
    Forum Contributor
    Join Date
    08-21-2014
    Location
    London
    MS-Off Ver
    Office 365
    Posts
    232

    Re: Formula to filter results from data

    Thanks - works on the sample data but having real trouble getting correct output when I apply to my actual data. The above isn't taking into account column N or O differences also. Will pick up again in morning as my brain is fried.

+ 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. Macro: Filter spreadsheet, then apply formula to results
    By RC-AMG in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-26-2015, 08:14 AM
  2. [SOLVED] Loop through Auto Filter Criteria and Copy Formula Results Into New Sheet
    By hamidxa in forum Excel Programming / VBA / Macros
    Replies: 11
    Last Post: 05-21-2014, 05:34 PM
  3. Auto filter data and copy results to another worksheet?
    By thisiscrazy in forum Excel Programming / VBA / Macros
    Replies: 14
    Last Post: 04-24-2012, 07:46 AM
  4. Filter Results Shown In Data Validation List
    By Spencer in forum Excel General
    Replies: 19
    Last Post: 03-15-2011, 05:15 AM
  5. Data filter - count number of results
    By mdraper in forum Excel General
    Replies: 1
    Last Post: 09-01-2010, 11:40 PM
  6. Replies: 3
    Last Post: 03-31-2010, 11:47 AM
  7. Results of List of Data with Advanced Filter
    By vtphilk in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-07-2008, 06:21 PM

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