• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Selecting randomly three unique rows per user

joj_john

New Member
Hello I am new member. My name is Jolly

For audit purposes, I need to select 3 notes per physician from a database (see attached excel sheet). They are namely Discharge Summary, Progress Notes, History and Physical from different dates.
Currently I am using the If function and assigning values for each note type. Then using the pivot table randomly pick 3 notes. Please see excel sheet Alex brit.
I am sure there is an easier way. Awaiting your advice and help.
 

Attachments

  • random selection of note types.xlsx
    43.2 KB · Views: 4
If you have Office 365, you can use a combination of UNIQUE and RANDARRAY with a couple of other functions.
[G7]=UNIQUE(staff3[Physician])
[H6]=TRANSPOSE(UNIQUE(staff3[Note Type]))
[H7]=BYCOL($H$6#;LAMBDA(Note;LET(
data;FILTER(staff3[Medical Record Number];(staff3[Physician]=G7)*(staff3[Note Type]=Note));
Count;COUNTA(data);
Random;INDEX(data;RANDARRAY(1;;1;Count;TRUE));Random)))

True wizards over here manage to this in a single formula. For me the nested arrays are in the way.
 

Attachments

  • random selection of note types.xlsx
    46.5 KB · Views: 0
Formula in cell G7
or, same formula converted to a lambda formula in cell L7
Generate new random selection by sorting column E.
I've been lazy in not trying to include the randomisation within the formula.
(Confused the hell out of me until I discovered randbetween in column B!)
 

Attachments

  • Chandoo56540random selection of note types2.xlsx
    71.9 KB · Views: 1
Back
Top