+ Reply to Thread
Results 1 to 27 of 27

Exclude data conflicts and then match remaining Data

  1. #1
    Registered User
    Join Date
    11-07-2018
    Location
    Sydney Australia
    MS-Off Ver
    2016 Pro
    Posts
    74

    Exclude data conflicts and then match remaining Data

    Hello again all,

    I have another matching puzzle to solve, previously Jindon was able to solve my 2 way preference matching, Thanks again @Jindon!! but this time I have a some other variables with 1 way preferences.

    Ok...

    My goal is to Match a list of 1-10000 USERID's with an appropriate SITEID.

    I have a full table of SITEID's.

    The USERID data will come in as a row in Excel, which shows:
    1. USERID (Which is Numeric)
    2. States of Australia to Exclude (could also be none)
    3. 0 - 50 SITEID's to Exclude (alpha/numeric and numeric)
    4. 0 - 5 SITEID Preferences (alpha/numeric and numeric)


    My Matching algorithm includes the following rules:
    1. Exclude USERID States from corresponding list of SITEID States (For example if a USERID inputs NSW and VIC, they will be excluded from all SITEID's in these states, could also have none)
    2. Exclude USERID Conflict SITEID's A (e.g. If a USERID inputs 0-50 SITEID's, they will be excluded from their choice of SITEID's)
    3. Match a USERID to SITEID Preference Match - they may input 0-5 preferences, (e.g. If the USERID's preference 1 matches a SITEID from the remaining list of SITEID's let over after Exclusions then Show the match in a new Cell, (Preferences have order of priority)
    4. If there are no SITEID's to match the preferences show "No Match"

    So a full Example might be:
    USERID 111 identifies NSW and VIC to be excluded
    USERID 111 identifies SITEID 111, SITEID 112 and SITEID 113 to be excluded
    USERID 111 preferences are SITEID's 115, 116 and 117
    As SITEID 115 is in NSW this SITEID isn't available, so the algorithm tries preference 2 - SITEID 116
    SITEID 116 is in QLD so we have a match of USERID 111 and SITEID 116
    Then the Algorithm moves to the next USERID
    (If the algorithm couldn't match any SITEID's from the USERID preferences then it would show "NO MATCH")
    (Some SITEID don't have a State assigned or aren't in Australia so these can also show "NO MATCH")


    Multiple USERID's can match the same SITEID's
    Each USERID starts with a full list of SITEID's before exclusions occur

    So the end product will show in the last column for each row (Each USERID), something like:
    SITEID 111
    SITEID 5435
    No Match
    SITEID 3267
    No Match
    No Match
    SITEID 111

    and so on.

    I have attached the spreadsheet and I believe the solution is to Reference the STATEEXCLUSIONS against the StateTable (Table 2) as a dictionary, and Reference the SITEEXCLUSIONS against the SITETABLE (Table 1) as a dictionary to Exclude them from the full Site list and then Match the SITEPREFERENCES. I just can't write the syntax correctly.

    Cheers

    *Note: This isn't listed on any other forums etc
    Attached Files Attached Files
    Last edited by Lee_of_Excel; 09-02-2020 at 09:45 PM.

  2. #2
    Registered User
    Join Date
    11-07-2018
    Location
    Sydney Australia
    MS-Off Ver
    2016 Pro
    Posts
    74

    Re: Exclude data conflicts and then match remaining Data

    The previous matching code works in the same way, except it is matching USER PREFERENCES OF SITE against SITE PREFERENCES OF USER,

    I have tried to modify this but my coding skills are currently at the level to properly code the scripting dictionaries.

    I had a previous Unprotect, Protect code in here also which I will keep for this one too.

    Please Login or Register  to view this content.
    Last edited by Lee_of_Excel; 09-02-2020 at 09:34 PM.

  3. #3
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Exclude data conflicts and then match remaining Data

    re Your message,
    Confusing
    Quote Originally Posted by Lee_of_Excel View Post
    My goal is to Match a list of 1-10000 USERID's with an appropriate SITEID.

    I have a full table of SITEID's.

    The USERID data will come in as a row in Excel, which shows:
    1. USERID (Which is Numeric)
    2. States of Australia to Exclude (could also be none)
    3. 0 - 50 SITEID's to Exclude (alpha/numeric and numeric)
    4. 0 - 5 SITEID Preferences (alpha/numeric and numeric)

    My Matching algorithm includes the following rules:
    1. Exclude USERID States from corresponding list of SITEID States (For example if a USERID inputs NSW and VIC, they will be excluded from all SITEID's in these states, could also have none)
    2. Exclude USERID Conflict SITEID's A (e.g. If a USERID inputs 0-50 SITEID's, they will be excluded from their choice of SITEID's)
    3. Match a USERID to SITEID Preference Match - they may input 0-5 preferences, (e.g. If the USERID's preference 1 matches a SITEID from the remaining list of SITEID's let over after Exclusions then Show the match in a new Cell, (Preferences have order of priority)
    4. If there are no SITEID's to match the preferences show "No Match"
    Excliude from what?
    Quote Originally Posted by Lee_of_Excel View Post
    So a full Example might be:
    USERID 111 identifies NSW and VIC to be excluded
    USERID 111 identifies SITEID 111, SITEID 112 and SITEID 113 to be excluded
    USERID 111 preferences are SITEID's 115, 116 and 117
    As SITEID 115 is in NSW this SITEID isn't available, so the algorithm tries preference 2 - SITEID 116
    SITEID 116 is in QLD so we have a match of USERID 111 and SITEID 116
    Then the Algorithm moves to the next USERID
    (If the algorithm couldn't match any SITEID's from the USERID preferences then it would show "NO MATCH")
    (Some SITEID don't have a State assigned or aren't in Australia so these can also show "NO MATCH")


    Multiple USERID's can match the same SITEID's
    Each USERID starts with a full list of SITEID's before exclusions occur

    So the end product will show in the last column for each row (Each USERID), something like:
    SITEID 111
    SITEID 5435
    No Match
    SITEID 3267
    No Match
    No Match
    SITEID 111

    and so on.

    I have attached the spreadsheet and I believe the solution is to Reference the STATEEXCLUSIONS against the StateTable (Table 2) as a dictionary, and Reference the SITEEXCLUSIONS against the SITETABLE (Table 1) as a dictionary to Exclude them from the full Site list and then Match the SITEPREFERENCES. I just can't write the syntax correctly.
    Where can I find "USERID 111"?

  4. #4
    Registered User
    Join Date
    11-07-2018
    Location
    Sydney Australia
    MS-Off Ver
    2016 Pro
    Posts
    74

    Re: Exclude data conflicts and then match remaining Data

    Hi Jindon,

    Thanks for your reply.

    Apologies, I may have complicated it, I will try to explain it more simply:


    A person (USERID) is going to provide me with a list of states that they can't work in, for Example NSW and QLD.
    The person will also provide me with a list of Site ID's that they also can't work in (could be 0 to 50).
    The person will then provide me with a list of Site ID's that they would like to work in (Could be 0 - 5)

    That information will come in a single row.

    My job will be to match the person with their preferred site from their list of preferences.

    They can't be matched with a site that they say they can't work in, or a site from a state that they can't work in.

    Any that don't match for any reason can say "No Match"

    I only have 4 examples in the spreadsheet so far: UserID 11111, 15452,31267 and 24126. But if it helps I can import a full list of all UserID's.
    Last edited by Lee_of_Excel; 09-02-2020 at 11:04 PM.

  5. #5
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Exclude data conflicts and then match remaining Data

    OK, take 1st row i.e. USER ID = 11111

    STATE/TERRITORY EXCLUSIONS = VIC
    SITE EXCLUSIONS = 1143(corresponding value in SITE_TABLE = VIC) at SITE_ID_4
    SITE PREFERENCES = 717(corresponding value in SITE_TABLE = Blank) at SITE PREFERENCES

    What is the output and why?

  6. #6
    Registered User
    Join Date
    11-07-2018
    Location
    Sydney Australia
    MS-Off Ver
    2016 Pro
    Posts
    74

    Re: Exclude data conflicts and then match remaining Data

    Ok cool thanks,
    for USER ID = 11111
    STATE/TERRITORY EXCLUSIONS = VIC
    SITE EXCLUSIONS = 1143(corresponding value in SITE_TABLE = VIC) at SITE_ID_4
    SITE PREFERENCES = 717(corresponding value in SITE_TABLE = Blank) at SITE PREFERENCES

    So their site preference of 717 doesn't have a State assigned - so in this case It would be "NO Match" and I would need to manually contact this person to discuss left over available sites after all of the Matches had been processed.

    My main goal is to match as many People as possible, but where the data is not yet perfect, we will need to manually contact the person and manually match.

    (The data is currently being updated and cleansed so I can run the algorithm multiple times as the data becomes better)

  7. #7
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Exclude data conflicts and then match remaining Data

    If that's the case, it only needs to search what is in SITE PREFERENCES against SITE_TABLE and return the result(s)(corresponding value) and when it is blank, mark as "No match".

    Is this correct? or am I still missing something?

  8. #8
    Registered User
    Join Date
    11-07-2018
    Location
    Sydney Australia
    MS-Off Ver
    2016 Pro
    Posts
    74

    Re: Exclude data conflicts and then match remaining Data

    For another Example:

    USER ID = 31267
    STATE/TERRITORY EXCLUSIONS = NSW and WA
    SITE EXCLUSIONS = 1640 and 1670 (as well as all in NSW and WA)BLANK
    SITE PREFERENCES = Preference 1 = 1640, Preference 2 = 1670, Preference 3 = 81, Preference 4 = 422, Preference 5 = BLANK

    1640 is in WA so they can't work there
    1670 is in NSW so they Can't work there
    81 is in NSW so they can't work there
    422 is in NT so this would be a Match

    So in Column 'BM' it would say 422

    Then the algorithm would move to the next row

  9. #9
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Exclude data conflicts and then match remaining Data

    In the case above, how would be the output for that row?

    And one more,
    Say if
    STATE/TERRITORY EXCLUSIONS = NSW
    SITE EXCLUSIONS = None
    SITE PREFERENCES =1143(VIC)
    When something like this happens, it still need to exclude 1143?.
    I mean exclude all the states in STATE_TABLE?

  10. #10
    Registered User
    Join Date
    11-07-2018
    Location
    Sydney Australia
    MS-Off Ver
    2016 Pro
    Posts
    74

    Re: Exclude data conflicts and then match remaining Data

    Quote Originally Posted by jindon View Post
    If that's the case, it only needs to search what is in SITE PREFERENCES against SITE_TABLE and return the result(s)(corresponding value) and when it is blank, mark as "No match".

    Is this correct? or am I still missing something?
    Yes that is correct, it only needs to SITE PREFERENCES against the SITE _TABLE (excluding the SITE EXCLUSIONS AND STATE EXCLUSIONS)

    If the preferences are Blank, then mark as "No Match"
    If the State is missing beside a SITE_ID in the SITE_TABLE that was their preference it will also be "No Match" (Unless one of their other preferences can be matched)

    For Example if:
    USER ID = 31267
    STATE/TERRITORY EXCLUSIONS = NSW and WA
    SITE EXCLUSIONS = 1640 and 1670 (as well as all in NSW and WA)BLANK
    SITE PREFERENCES = Preference 1 = 1640, Preference 2 = 1670, Preference 3 = 81, Preference 4 = 422, Preference 5 = BLANK

    1640 is in WA so they can't work there
    1670 is in NSW so they Can't work there
    81 is in NSW so they can't work there
    422 WAS in Blank for state, then it would look at preference 5 (if they had one)
    In this example, if they had preference 5 = 1324 (Tas) they would have a match on preference 5

    So in Column 'BM' it would say 1324

  11. #11
    Registered User
    Join Date
    11-07-2018
    Location
    Sydney Australia
    MS-Off Ver
    2016 Pro
    Posts
    74

    Re: Exclude data conflicts and then match remaining Data

    Quote Originally Posted by jindon View Post
    In the case above, how would be the output for that row?

    And one more,
    Say if
    STATE/TERRITORY EXCLUSIONS = NSW
    SITE EXCLUSIONS = None
    SITE PREFERENCES =1143(VIC)
    When something like this happens, it still need to exclude 1143?.
    I mean exclude all the states in STATE_TABLE?
    The output can just show the SITE_ID of the match in Column 'BM', if there is no match the output can just say "No Match" - basically the end product will be a full list of USER_ID and Matched SITE_ID = e.g. 31267 and 422

    For:
    STATE/TERRITORY EXCLUSIONS = NSW
    SITE EXCLUSIONS = None
    SITE PREFERENCES =1143(VIC)
    It would only Exclude sites in NSW, so 1143(VIC) would a correct match

    I have attached a Picture that might help
    Attached Images Attached Images
    Last edited by Lee_of_Excel; 09-02-2020 at 11:57 PM.

  12. #12
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Exclude data conflicts and then match remaining Data

    OK, this is how I understand...

    1) Check the columns B:BG and get all states that you want to exclude.
    2) Check the columns BH:BL and see if their corresponding State are listed in 1)
    3) If corresponding state is not in the list, output the number in that cell, when corresponding state is blank, "No Match".

    If above is true, what if there are multiple valid results?
    Say one or even more has the corresponding state(s) that is not in the list and one/more has blank(s)?

  13. #13
    Registered User
    Join Date
    11-07-2018
    Location
    Sydney Australia
    MS-Off Ver
    2016 Pro
    Posts
    74

    Re: Exclude data conflicts and then match remaining Data

    Yes thats all correct,

    For multiple valid results, is it possible just to show only the first valid result?

    If not, could we have these output all valid results in the next columns (e.g. BM, BN, BO, BP and BQ?

  14. #14
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Exclude data conflicts and then match remaining Data

    Both are possible and even multiple results in one cell.
    All I need to know is how you want it.

  15. #15
    Registered User
    Join Date
    11-07-2018
    Location
    Sydney Australia
    MS-Off Ver
    2016 Pro
    Posts
    74

    Re: Exclude data conflicts and then match remaining Data

    Excellent, in that case, can I please have the output of all valid results in the next columns (e.g. BM, BN, BO, BP and BQ?

  16. #16
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Exclude data conflicts and then match remaining Data

    This is to test the results if the logic is correct or not, so still need more error trap.
    Please Login or Register  to view this content.
    Last edited by jindon; 09-03-2020 at 07:55 AM. Reason: Found a bug and fixed.

  17. #17
    Registered User
    Join Date
    11-07-2018
    Location
    Sydney Australia
    MS-Off Ver
    2016 Pro
    Posts
    74

    Re: Exclude data conflicts and then match remaining Data

    Awesome! Thanks very much! i'll get some live data in the morning and test it out. Cheers

  18. #18
    Registered User
    Join Date
    11-07-2018
    Location
    Sydney Australia
    MS-Off Ver
    2016 Pro
    Posts
    74

    Re: Exclude data conflicts and then match remaining Data

    Hi Jindon,

    Thanks again for your work on this,

    I tested the logic on our example USER_ID's and got the following results:

    USER_ID = 11111, Result = 717, but should be "No Match"
    USER_ID = 15452, Result = 1510, but should be "1676"
    USER_ID = 31267, Result = 422, which is correct
    USER_ID = 15452, Result = Blank, which should be "no match'

    The reasons:
    USER_ID = 11111, Result = 717, but should be "No Match" - because 717 has no corresponding state in the Site_Table, so we don't know if it is in a state that the user can't work in and will have to be manually completed
    USER_ID = 15452, Result = 1510, but should be "1676" - because this user reported that they couldn't work in SA or Site 83 and their first preference was 1676 which is in QLD, so 1676 will be a correct match
    USER_ID = 31267, Result = 422, which is correct - the user identified that they couldn't work in NSW and WA and site 1640, and site 1670. 1640 and 1670 were their 1st and 2nd preference so they couldn't have them and their 3rd preference was in NSW so they couldn't have that but their 4th preference was 422 in NT so that is a correct match
    USER_ID = 15452, Result = Blank, which should be "no match' - the user identified that they couldn't work in VIC or site 81 but had no preferences so the correct result is "no match" (which I think was the output your logic output)

  19. #19
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Exclude data conflicts and then match remaining Data

    That was the bug I have fixed after I posted, so copy the code again and try.

    Got the result from your attached workbook.

    717 (No Match)
    409 (No Match)
    422

  20. #20
    Registered User
    Join Date
    11-07-2018
    Location
    Sydney Australia
    MS-Off Ver
    2016 Pro
    Posts
    74

    Re: Exclude data conflicts and then match remaining Data

    Looks good, I think that the logic is working well now, this will work well thanks,

    Now that the logic is working well, can it output all 5 preference results in separate columns, I have updated the spreadsheet ready :-D
    Attached Images Attached Images
    Attached Files Attached Files

  21. #21
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Exclude data conflicts and then match remaining Data

    Is this the final format and the headers will not change?
    I mean header name for PREFERENCE_OUTPUT_#.

  22. #22
    Registered User
    Join Date
    11-07-2018
    Location
    Sydney Australia
    MS-Off Ver
    2016 Pro
    Posts
    74

    Re: Exclude data conflicts and then match remaining Data

    Yes this will be the final format, I be the only person viewing this spreadsheet so I didn't make it too pretty. cheers

  23. #23
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Exclude data conflicts and then match remaining Data

    As before, the code is looking at the merged areas in 1st row.
    As long as you keep the rule of merge, it should be flexible to increase/decrease columns.
    Please Login or Register  to view this content.

  24. #24
    Registered User
    Join Date
    11-07-2018
    Location
    Sydney Australia
    MS-Off Ver
    2016 Pro
    Posts
    74

    Re: Exclude data conflicts and then match remaining Data

    Great thanks, I think this is all working well now,

    If I add a vba line at the end to fill all blank spaces with "No Match" in the blank reference output fields, would that cause an issue?

    I was just thinking that in the future if someone has to fill in or assist me with using this spreadsheet, they might become confused.
    Attached Images Attached Images

  25. #25
    Forum Guru
    Join Date
    08-15-2004
    Location
    Tokyo, Japan
    MS-Off Ver
    2013 O.365
    Posts
    22,516

    Re: Exclude data conflicts and then match remaining Data

    You mean?
    Please Login or Register  to view this content.

  26. #26
    Registered User
    Join Date
    11-07-2018
    Location
    Sydney Australia
    MS-Off Ver
    2016 Pro
    Posts
    74

    Re: Exclude data conflicts and then match remaining Data

    Yes I think that might work, i'll give it a try

  27. #27
    Registered User
    Join Date
    11-07-2018
    Location
    Sydney Australia
    MS-Off Ver
    2016 Pro
    Posts
    74

    Re: Exclude data conflicts and then match remaining Data

    It is looking great Jindon, I have given it to some Colleagues to also test in case I missed anything

+ 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. how to eliminate certain data from the worksheet and then sort the remaining data
    By sumesh56 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 03-20-2018, 12:13 PM
  2. Macro to clear row data then shift remaining data up to empty rows.
    By clarmech in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-15-2014, 04:35 PM
  3. Exclude items from Data Validation List based on another columns data
    By amartin575 in forum Excel Formulas & Functions
    Replies: 0
    Last Post: 09-19-2013, 11:53 AM
  4. Index/match or Vlookup to exclude data
    By MZing81 in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-21-2012, 03:32 PM
  5. How to find match data and exclude with condition
    By buvan in forum Excel General
    Replies: 2
    Last Post: 11-17-2011, 06:51 AM
  6. exclude a match condition between two data fields
    By rhiekel in forum Excel General
    Replies: 6
    Last Post: 04-22-2011, 10:53 AM
  7. [SOLVED] Adding data to celss but keeping the remaining data intact.
    By TP in forum Excel General
    Replies: 4
    Last Post: 04-12-2006, 09:20 PM

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