+ Reply to Thread
Results 1 to 9 of 9

randbetween / index with conditions and without duplicates

  1. #1
    Registered User
    Join Date
    08-25-2020
    Location
    France
    MS-Off Ver
    2007
    Posts
    3

    randbetween / index with conditions and without duplicates

    Hi,

    I have the following issue, any help would be much appreciated as I am not an excel expert at all...

    I have a list of cases B4:B1003 with corresponding owners C4:C1003, few rows are empty (different numbers of cases each month).
    For quality check, I want to assign 10% of total number of cases (number of cases to be reviewed calculated in I2) to 5 team members (table E4:I23).
    The team members must not review their own cases (column C), they should not review a case already assigned to another team member and there must not be a duplicate in the total list of cases to be reviewed.

    I finally did :
    for the first team mamber =INDEX($B$4:$B$1003;RANDBETWEEN(1;COUNTIFS($C$4:$C$1003;"<>User 1";$C$4:$C$1003;"<>")))
    the second one =INDEX($B$4:$B$1003;RANDBETWEEN(1;COUNTIFS($C$4:$C$1003;"<>User 2";$C$4:$C$1003;"<>";$C$4:$C$1003;"<>$E$4:$E$23")))
    the third one =INDEX($B$4:$B$1003;RANDBETWEEN(1;COUNTIFS($C$4:$C$1003;"<>User 3";$C$4:$C$1003;"<>";$C$4:$C$1003;"<>$E$4:$F$23")))
    etc... adding a column each time to avoid preassigned cases to other team members in the last condition criteria of the formula

    I tryed with index, randbetween, coutifs, rank as I am not good in VBA... I am a bit lost and need your help because using a large amount of case I get some mistakes (duplicates or case assigned to the owner for review).

    Many thanks in advance for your support!
    Attached Files Attached Files

  2. #2
    Banned User!
    Join Date
    02-06-2020
    Location
    Iowa City, IA, USA
    MS-Off Ver
    2016 - 365 / 2007
    Posts
    2,014

    Re: randbetween / index with conditions and without duplicates

    well, I might be able to offer something here. you said:
    Quote Originally Posted by LovelyDay83 View Post
    For quality check, I want to assign 10% of total number of cases (number of cases to be reviewed calculated in I2) to 5 team members (table E4:I23).
    that is fine, and perfectly understandable, however you have RANDBETWEEN in your calc'd formulas and nests. the purpose of [RAND]-oriented anything in terms of a function is to return randomness in some form. see here for your function:

    https://support.microsoft.com/en-us/...f-a469ab381685

    I did not replicate your issue, however are you sure you want randomization in your formulas? it doesn't sound like you need it and/or it should even be relevant.

  3. #3
    Forum Guru
    Join Date
    08-05-2004
    Location
    NJ
    MS-Off Ver
    365
    Posts
    13,582

    Re: randbetween / index with conditions and without duplicates

    I used two helper helper columns to randomize and rank. I use RAND() rather than RANDBETWEEN() because RAND produces a number with 15 digits and the likelihood of duplicates is extremely rare. The only issue with my formula is cosmetic as it will leave blank spaces where the value matches up to the same user. I tried using AGGREGATE but it ended up giving me duplicates. I'm sure one of the other gurus can come up with a better solution.
    In D4 copied down to D1003
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    In E4, copied down to E1003
    Formula: copy to clipboard
    Please Login or Register  to view this content.

    Then in G4 copied across and down
    Formula: copy to clipboard
    Please Login or Register  to view this content.
    Does that work for you?
    Attached Files Attached Files
    ChemistB
    My 2?

    substitute commas with semi-colons if your region settings requires
    Don't forget to mark threads as "Solved" (Edit First post>Advanced>Change Prefix)
    If I helped, Don't forget to add to my reputation (click on the little star at bottom of this post)

    Forum Rules: How to use code tags, mark a thread solved, and keep yourself out of trouble

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,809

    Re: randbetween / index with conditions and without duplicates

    You don't share any details of what you have tried, so you might have already tried this. I would approach this problem as a "sorting" problem rather than a randbetween problem.

    1) Assign each case a random unique number (I usually use RAND()).
    1a) To deal with a variable length list, nest inside of an IF() function to only assign a random number when there is a case. L4 =IF(A4="","",RAND())
    2) Rank/Sort the list of random numbers M4 =IFERROR(RANK(L4,$L$4:$L$1003),"")
    3) A lookup function to find the top 10 random numbers
    3a) Enter the numbers 1 to 10 in N4:N13
    3b) In O4, =MATCH(N4,$M$4:$M$1003,0)
    3c) One or more INDEX() functions to extract the case information. P4 =INDEX($B$4:$B$1003,O4)
    4) Assign users to the cases, with a check to make sure you don't assign a user his/her own case.

    Will something like that work for you?
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  5. #5
    Forum Expert
    Join Date
    07-06-2004
    Location
    Northern California
    MS-Off Ver
    2K, 2003, 2010, O365
    Posts
    1,490

    Re: randbetween / index with conditions and without duplicates

    To rephrase, you have case IDs in col B and employee IDs for the employee responsible for each case in col C. You want to sample 10% of cases, assigning them to any of the employees EXCEPT the one shown in col C, and you want to avoid the same case being assigned to multiple employees.

    Add a single column of additional formulas. That formula should be =RAND() . I'll assume this is in col D, and that B4:D1003 is named CaseTable.

    I'll assume you have a list of IDs for all the employees who could review cases in one column and the formula =RAND() in the column immediately to the right of those IDs, and that this 2-column range is named EmployeeTable. If you don't have such a table, create one.

    Then in another worksheet, you can pull a sample of 10% of cases using formulas like this.

    A3: =MATCH(LARGE(INDEX(CaseTable,0,3),ROWS(A$3:A3)),INDEX(CaseTable,0,3),0)
    B3: =INDEX(CaseTable,$A3,1)
    C3: =INDEX(CaseTable,$A3,2)
    D3: =INDEX(EmployeeTable,MATCH(LARGE(INDEX(INDEX(EmployeeTable,0,2)*(INDEX(EmployeeTable,0,1)<>C3),0),1+MOD(ROWS(D$3:D3)-1,ROWS(EmployeeTable)-1)),INDEX(EmployeeTable,0,2),0),1)

    Fill A3:D3 down into A4:D102. Each month, recalculate the workbook, then copy this table, A3:D102, and paste special as values somewhere else. That'd be the review schedule for the month, with meaningless number in col A, case ID in col B, ID for the employee responsible for that case in col C, and ID for the employee to review that case in col D.

    The idea here is that you want random sampling without replacement. That's most easily accomplished by sorting in random order, which is what the formulas above would do.

    Note: this does NOT ensure reviewing employees (D3:D102) each review the same number of cases. However, you should be able to balance review loads manually from the pasted special as value table.

  6. #6
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: randbetween / index with conditions and without duplicates

    Hi there,

    Take a look at the attached version of your workbook and see if it does what you need. It uses the following code:

    Please Login or Register  to view this content.
    The highlighted values may be altered to suit your requirements.


    Hope this helps - please let me know how you get on.

    Regards,

    Greg M


    P. S. Sorry! I misread your original post - this does not prevent the same case being assigned to more than one reviewer.

    I'll see if I can post something to address this.
    Attached Files Attached Files
    Last edited by Greg M; 09-23-2020 at 05:13 PM. Reason: P. S. added

  7. #7
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: randbetween / index with conditions and without duplicates

    Hi again,

    Take a look at the attached version of your workbook and see if it works better than the one I posted previously. The workbook uses the following code:

    Please Login or Register  to view this content.
    The highlighted values may be altered to suit your requirements.


    Hope this helps - please let me know how you get on.

    Regards,

    Greg M
    Attached Files Attached Files

  8. #8
    Registered User
    Join Date
    08-25-2020
    Location
    France
    MS-Off Ver
    2007
    Posts
    3

    Re: randbetween / index with conditions and without duplicates

    Many thanks to all of you for your great support!! I will work on it following your recommendations and get back to you if needed.
    Thanks again, you are awesome!!!

  9. #9
    Forum Expert Greg M's Avatar
    Join Date
    08-16-2007
    Location
    Dublin. Ireland
    MS-Off Ver
    Office 2016
    Posts
    4,481

    Re: randbetween / index with conditions and without duplicates

    Hi again,

    Many thanks for your feedback and also for the Reputation increase - much appreciated!

    You're welcome - glad I was able to help.

    Best regards,

    Greg M

+ 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. [SOLVED] RANDBETWEEN dates with no duplicates
    By focalfox in forum Excel Formulas & Functions
    Replies: 4
    Last Post: 03-07-2020, 03:23 PM
  2. RandBetween - No Duplicates in Column
    By stewarttracy in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 07-11-2018, 04:36 PM
  3. Separation of duplicates with RANDBETWEEN
    By wyturieowk in forum Excel General
    Replies: 1
    Last Post: 04-30-2017, 03:18 PM
  4. [SOLVED] Randbetween with No Duplicates
    By novice1239 in forum Excel General
    Replies: 6
    Last Post: 03-19-2017, 10:17 AM
  5. Issue with LARGE, MATCH, INDEX and duplicates, multiple conditions
    By Toddowhams in forum Excel Formulas & Functions
    Replies: 5
    Last Post: 01-05-2017, 03:08 PM
  6. Randbetween without duplicates
    By Williamdry in forum Excel Formulas & Functions
    Replies: 1
    Last Post: 07-29-2014, 09:27 AM
  7. Index/Match with Conditions and Duplicates
    By ddapcn in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 11-09-2012, 03:50 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