web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Random employee audit
Power Apps
Unanswered

Random employee audit

(0) ShareShare
ReportReport
Posted on by 6

I'm trying to build a random associate audit, and I'm having trouble with the logic. All the data is stored in sharepoint lists and I have an associate table (basic ID, name and Last_Audit_Date) / manager table (mostly helps with having a distinct list of managers (plus permissions)).

 

At the click of a button, I want to generate an audit for a random associate for each manager. I planned to "ForAll(managers, collect first associate with the oldest audit date (pulling nulls first)" but it seems I can't nest a clearcollect in a ForAll, and I'm not sure how to proceed.

 

Every manager has a different amount of associates so can't hard code any numbers. Once I have the random associate, I plan on patching to the audit table to track audit history.

Categories:
  • TheRobRush Profile Picture
    11,128 Moderator on at

    You could achieve a random order in several ways, here is one of them.

     

     

     

    ///Initiate ClearCollect
    ClearCollect(
     ///CollectionName
     RandomList,
     ///Sort This Data
     Sort(
     ///Check ALl applicable Data
     ForAll(
     ///Source is SPList TROSTER
     TMROSTER,
     {
     ////Columns we wil haae in our new collection 
     Identifier:ID, 
     EmployeeName:Title, 
     RandomSelf:Rand()
     }
     ),
     ////Column to Sort by
     RandomSelf,
     ///Order to sort in
     Ascending))

     

     

     

    You could even further break this down with other checks and modifiers etc

  • TheRobRush Profile Picture
    11,128 Moderator on at

    The random employee would just be the First(RandomList).EmployeeName forgot to clarify. but will be different and random every time

  • timl Profile Picture
    37,418 Super User 2026 Season 2 on at

    @Damiancds 

    The Shuffle function provides a really easy way to retrieve a random record.

    https://docs.microsoft.com/en-gb/powerapps/maker/canvas-apps/functions/function-shuffle 
    Therefore, you can call the AddColumns function on your manager list to include a column that contains a random associate record.

    AddColumns(ManagerList,
     "RandomAssociateRecord",
     First(Shuffle(
     Filter(AssociateList,
     ManagerID=ManagerList[@ManagerID]
     )
     )
    ) 
    
  • CU20121617-0 Profile Picture
    6 on at

    I apologize for not coming back sooner. I was able to implement the solution from @timl, and it appears to work, but I am running into some weird issues.

     

    This is my current code: 

    ClearCollect(AssociateAudit,AddColumns('2920_Manager_List',"Associate",First(Shuffle(Filter('2920_Associate_List',Status ="Active" && Supervisor = '2920_Manager_List'[@Supervisor])))));

    when I look at the collection in a gallery, I have to access the associate by using 

    ThisItem.Associate.Associate

    And when I throw the collection in a data table, it shows the associate as [object Object].

     

    Am I joining these incorrectly? I would assume that I should be able to say ThisItem.Associate and have it be the text column and not treat it like an object/record?

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 220 Super User 2026 Season 2

#2
WarrenBelz Profile Picture

WarrenBelz 194 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 150

Last 30 days Overall leaderboard