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:
I have the same question (0)
  • 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
    36,713 Super User 2026 Season 1 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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 542 Most Valuable Professional

#2
Haque Profile Picture

Haque 206

#3
Kalathiya Profile Picture

Kalathiya 201 Super User 2026 Season 1

Last 30 days Overall leaderboard