+ Reply to Thread
Results 1 to 10 of 10

Returning a 1 if the rules are met

  1. #1
    Registered User
    Join Date
    07-15-2017
    Location
    England
    MS-Off Ver
    2010
    Posts
    5

    Returning a 1 if the rules are met

    Hi,

    Been scanning the forum to see if there is something similar, but can't find anything that works. Hopefully someone will be able to help.

    I need a formula which looks at certain columns and if the criteria match's, it returns a 1.


    The first is on example 1

    the formula needs to find a match in column J
    in column N a SG has to be a debit value (in black) in column U and a DQ needs to be a credit value (in red) in column U
    if the credit and debit match (it equals zero) it returns a 1 in column W on them entries


    The second example is the same but looks at the Doc.Date in column Q also.

    Again needs to find a match in column J
    in column N a SL has to be a debit value in column U and a SG needs to be credit value in column U
    It needs to look at the Doc Date in column R but minus 1 day of that date (so the credits on the 7th will match against the debits on the 6th)
    if it match's to zero it returns a 1 in column W on them entries


    Can anyone help? I can go into it more if the above doesn't make sense.

    Thank you in advance!
    Attached Files Attached Files
    Last edited by Craig123486; 07-22-2017 at 07:55 AM.

  2. #2
    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
    30,810

    Re: Returning a 1 if the rules are met

    For "Example 1"

    "Helper" in Column X

    in X2

    =IF(N2="SG",MATCH(-U2,$U$2:$U$1000,0),"")

    copy down

    in W2

    =IF(X2<>"",IF(AND(INDEX($N$2:$N$1000,X2)="DQ",INDEX($J$2:$J$1000,X2)=J2),1,""),"")

    Can you see if this correct: meanwhile I will look at "Example 2
    Attached Files Attached Files

  3. #3
    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
    30,810

    Re: Returning a 1 if the rules are met

    For "example 2"

    In X2

    =IF(N2="SL",IFERROR(MATCH(-U2,$U$2:$U$1000,0),""),"")

    Copy down

    in W2

    =IF(X2<>"",IF(AND(INDEX($J$2:$J$1000,X2)=J2,INDEX($R$2:$R$1000,X2)=R2+1),1,""),"")
    Attached Files Attached Files

  4. #4
    Registered User
    Join Date
    07-15-2017
    Location
    England
    MS-Off Ver
    2010
    Posts
    5

    Re: Returning a 1 if the rules are met

    Example 1

    Thanks for your reply

    I got the columns wrong the SG and SL are in column M and the values are in column T(my bad)

    I did put the formula in (just changed the column letters)

    =IF(M2="SG",MATCH(-T2,$T$2:$T$1000,0),"")

    &

    =IF(X2<>"",IF(AND(INDEX($M$2:$M$1000,X2)="DQ",INDEX($J$2:$J$1000,X2)=J2),1,""),"")

    In W2 it did return 1's but only for the debits

  5. #5
    Registered User
    Join Date
    07-15-2017
    Location
    England
    MS-Off Ver
    2010
    Posts
    5

    Re: Returning a 1 if the rules are met

    Example 2

    It did return 1's but just for debits and only 7 of them

    I can go into more detail if I am not making much sense

  6. #6
    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
    30,810

    Re: Returning a 1 if the rules are met

    Not in your posted files. N and U

  7. #7
    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
    30,810

    Re: Returning a 1 if the rules are met

    Try in "Example 1"

    in W2

    =IF(OR(M2="SG",M2="DQ"),MATCH(-T2,$T$2:$T$1000,0),"")

    in V2

    =IF(W2<>"",IF(OR(AND(INDEX($M$2:$M$1000,W2)="DQ",INDEX($J$2:$J$1000,W2)=J2),AND(INDEX($M$2:$M$1000,W2)="SG",INDEX($J$2:$J$1000,W2)=J2)),1,""),"")

    in Example 2

    in w2

    =IF(OR(M2="SL",M2="SG"),IFERROR(MATCH(-T2,$T$2:$T$1000,0),""))

    in V2

    =IF(W2<>"",IF(OR(AND(INDEX($J$2:$J$1000,W2)=J2,INDEX($Q$2:$Q$1000,W2)=Q2+1),AND(INDEX($J$2:$J$1000,W2)=J2,INDEX($Q$2:$Q$1000,W2)=Q2-1)),1,""),"")
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    07-15-2017
    Location
    England
    MS-Off Ver
    2010
    Posts
    5

    Re: Returning a 1 if the rules are met

    Ok I will give this a go

  9. #9
    Registered User
    Join Date
    07-15-2017
    Location
    England
    MS-Off Ver
    2010
    Posts
    5

    Re: Returning a 1 if the rules are met

    In example 1

    It's returning a lot of 1's but the overall value is not zero as it appears to have include credit 1's and not its relating debit and debits and not its matching credit

    Thank you for your help - I will return to this in the evening to show What I am getting
    Last edited by Craig123486; 07-22-2017 at 09:39 AM.

  10. #10
    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
    30,810

    Re: Returning a 1 if the rules are met

    See the attached.

    Column X shows the value corresponding to that in T: there is duplication because each entry shows its opposing entry i.e Credit shows Debit and the Debit will show the Credit.
    Attached Files Attached Files

+ 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. Replies: 11
    Last Post: 07-20-2017, 11:26 AM
  2. [SOLVED] Average returning #div/0 and sum/count returning 0
    By Sinnie in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 02-12-2016, 12:01 PM
  3. conditional formatting rules for a cell on sheet 1 based on rules from sheet 2
    By jsard in forum For Other Platforms(Mac, Google Docs, Mobile OS etc)
    Replies: 1
    Last Post: 08-15-2013, 09:22 AM
  4. [SOLVED] Outlook 2010 - Creating Rules - Rules Constant
    By Jack7774 in forum Outlook Formatting & Functions
    Replies: 3
    Last Post: 03-18-2013, 03:48 PM
  5. Replies: 3
    Last Post: 05-03-2012, 04:00 PM
  6. Formula sometimes returning correct answer and sometimes returning 0
    By redimp in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 09-09-2010, 06:28 AM
  7. help with IF rules
    By jon@karhu in forum Excel Formulas & Functions
    Replies: 8
    Last Post: 01-08-2009, 11:56 AM

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