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 / Setting variable by sh...
Power Apps
Unanswered

Setting variable by sharepoint list item

(0) ShareShare
ReportReport
Posted on by 290

Hello!

 

I want to set a variable based on sharepoint list under certain condition.

I have this list:database123.png

 As you can see, Employees are split into positions and departmens.

 

Lets imagine that I login into the app as a Manager from Finance department. I want to set a variable that IF there is a team leader in my department, the value of the variable will be true, but IF there are only employees and me as a manager (that means no one from my department is a team leader), the value will be false. 

 

Is that possible?

 

Categories:
  • Nogueira1306 Profile Picture
    7,390 Super User 2024 Season 1 on at

    Ok

     

    OnStart: Set(varUser; LookUp(myList; Employee = User().FullName))

    Set(varDepartment; Filter( myList; Department = varUser.Department))

     

    If( CountRows(Filter(varDepartment; Position = "Team Leader")) >=1; true, false)


    So, first you are getting the department of the suer that is logged in
    Then, getting the people on his department

    Then, checking if there is 1 or more team leader on that department. If yes, it return true if not, false

  • PriyankaGeethik Profile Picture
    3,320 Super User 2024 Season 1 on at

    Hi @Filistyn ,

    Please see the below code if it helps. 

     

    Set(varMyDept,LookUp(Employees,NameOfEmployee = User().FullName).Department); /*Set your Department*/
    
    If(IsEmpty(Filter(Employees,Department=varMyDept && Position="Team leader")),Set(varTeamLeader,false),(varTeamLeader,true)) /*Check if TeamLeaderPresent*/
    

     

     

  • Filistyn Profile Picture
    290 on at

    Hello, thank you for your advice.

     

    I have tried it out, but the value of varTeamLeader is false while im set as a team leader in the list.false.png

     

  • Filistyn Profile Picture
    290 on at

    Does not work, it says, that If has invalid arguments

  • Filistyn Profile Picture
    290 on at

    There was a Set missing 

    Set(varMyDept,LookUp(Employees,NameOfEmployee = User().Email).Department); /*Set your Department*/
    
    If(IsEmpty(Filter(Employees,Department=varMyDept && Position="Team Leader")),Set(varTeamLeader,true),Set(varTeamLeader,false)) 

     

    still does not work, tried it out in label, shows always false

  • PriyankaGeethik Profile Picture
    3,320 Super User 2024 Season 1 on at

    @Filistyn 

     

    Are you getting the Department correct in the variable ?

  • Filistyn Profile Picture
    290 on at

    If i want to display varMyDept, the label is empty. idk why

  • PriyankaGeethik Profile Picture
    3,320 Super User 2024 Season 1 on at

    @Filistyn 

     

    In Employee Name full names are there ? If everthing is stored in Lower case ? 

    Set(varMyDept,LookUp(Employees,NameOfEmployee = User().FullName).Department); /*Set your Department*/
    
    If(IsEmpty(Filter(Employees,Department=varMyDept && Position="Team Leader")),Set(varTeamLeader,true),Set(varTeamLeader,false)) 
  • Nogueira1306 Profile Picture
    7,390 Super User 2024 Season 1 on at

    It is empty beacuse of LookUp.. LookUp now only returns  the field that it tinks are necessary.

    Check this link

    http://powerappsguide.com/blog/post/how-does-the-explicit-column-selection-setting-work

     

    And you can try with filter

  • Filistyn Profile Picture
    290 on at

    Im using emails in the NameOfEmployee column and yes, everything is stored in lower case. For example if i use 

     LookUp(
     Employees,
     NameOfEmployee = User().Email
     ).Department
     

    In a label, it will display the right Department (and also in lower case)

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 189 Most Valuable Professional

#3
Mohsin Ali Profile Picture

Mohsin Ali 139

Last 30 days Overall leaderboard