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 / Retrieve a choice colu...
Power Apps
Answered

Retrieve a choice column value

(1) ShareShare
ReportReport
Posted on by 154

Hi,

I have a datavser table called 'End User' with the column below

Username: lookup column (see attach image)

Role: choice column with values(Director, Assistant, Registry).

I have already registered the users in the table.

Now, my purpose is to get in a variable, the role of the connected user when he runs the application.

Thanks

 

lookup column.PNG
Categories:
  • Hassan_SZ_365 Profile Picture
    542 on at

    Hi @Fahd ,

    you can use the following formula in PowerApps: 

     

    Set(CurrentUserRole, LookUp('End User', Username = User().Email).Role)

     

    This formula sets a variable named CurrentUserRole to the role value associated with the connected user's email address in the "End User" SharePoint list. Adjust the column names accordingly if they differ in your setup.

    Best Regards,

    Hassan Raza

     

  • M_Ali_SZ365 Profile Picture
    1,110 on at

    Hi @Fahd ,

    Try this 

    Set(CurrentUserRole, LookUp('End User', Username = User().Email).Role)

    Fuel our success! 🚀 Give a thumbs up and click 'Solution Accepted' to supercharge our community. Your actions speak volumes!
    Warm regards,
    Muhammad Ali

  • CU-18081211-6 Profile Picture
    9,272 Moderator on at

    @Fahd ,

    The standard approach should be:

    Set(CurrentUserRole, LookUp('End User', Username = User().Email).Role)

    Actually,in certain situation the PowerApps treat the result as a choice option value, and it cannot be used as it is.

    So to be sure that the result is indeed a string value use a Text() function.

    Set(CurrentUserRole, 
     Text(
     LookUp('End User', Username = User().Email).Role)
    )

     

  • Fada Profile Picture
    154 on at

    Hi,

    I have an error when running the app (see screenshots).

    Thanks

    code.PNG
    Error.PNG
  • M_Ali_SZ365 Profile Picture
    1,110 on at

    @Fahd ,

    Try This

    confirm 'End User' table exists.
    check 'Username' column as a lookup.
    Handle potential null values in code.

    Set(CurrentUserRole, LookUp('End User', Username = User().Email && !IsBlank(Username)).Role)

    Test with a known username.

    Set(CurrentUserRole, LookUp('End User', Username = "known@email.com").Role)

    Fuel our success! 🚀 Give a thumbs up and click 'Solution Accepted' to supercharge our community. Your actions speak volumes!
    Warm regards,
    Muhammad Ali

  • Fada Profile Picture
    154 on at

    Hi @M_Ali_SZ365 ,

    Your code does not work and it gives me a delegation warning.

    Fahd_0-1700202970920.png

     

    However, I have the correct role with the below code but it shows me a delegation warning. So now, my purpose is to handle the delegation issue.

    Set(
    varUserRole,
    LookUp(
    'End users',
    User().Email in 'User name'.Mail).Role)

     

    Fahd_1-1700203246014.png

     

     

    Thanks

  • M_Ali_SZ365 Profile Picture
    1,110 on at

    @Fahd ,

    Try This 

    For the delegation warning:

    Refine the lookup condition:

    Set(varUserRole, LookUp('End users', 'User name'.Mail = User().Email, Role))

    Filter before lookup:

    Set(varUserRole, LookUp(Filter('End users', 'User name'.Mail = User().Email), Role))

    Limit rows for large datasets:

    Set(varUserRole, First(LookUp(Filter('End users', 'User name'.Mail = User().Email), Role)))

    Test these for the delegation issue.

    Fuel our success! 🚀 Give a thumbs up and click 'Solution Accepted' to supercharge our community. Your actions speak volumes!
    Warm regards,
    Muhammad Ali

  • Verified answer
    Fada Profile Picture
    154 on at

    Hi @M_Ali_SZ365 , Still nothing, I have an error when running your code. Anyway, I take the risk of delegation.

    Fahd_0-1700690684710.png

    Thanks

     

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 411 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 338

#3
WarrenBelz Profile Picture

WarrenBelz 256 Most Valuable Professional

Last 30 days Overall leaderboard