Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

Select table based on current user.

(0) ShareShare
ReportReport
Posted on by

Hi, im working on an app for registering drive miles, for consultants.

The idea is:

when the app starts up, it checks the current User().FullName.

then i want it to write to a specific table according to which user is using the app.

i have created a table for each user. so if the user Consultant1 is running the app, it should read the table "Consultant1" and so on for Consultant 2,3,4,5 etc.

i have created the app from data source, and connected it to the first database, and its working. but now i want to implement the above function, so the different users dont see data from other users. So either it can check the user automatically in the background, or i can make a screen selection where the the user have to choose which person is using the app.

Im at a total blank point, since i dont know how to start on this.

ive attached 2 screenshots, the first screen how it looks for the user. when im logged in i see the data of the connected excel table.

2nd screenshot is excel sheet. each pane will contain the info from each user. but i dont know how to change the table which the user is connected to.

 

Sorry for the long wall of text, but wanted to explain it as well as i could.

If you could help with this i would be very grateful. Any code/guides and hints to where i can find info on this would be greatly appreciated.

 

Regards Henrik

Categories:
  • barbi Profile Picture
    barbi 2 on at
    Re: Select table based on current user.

    Hello, I am not sure I understood what you meant here but I am vrey interested because it could be helpful for my case:

    I created a table with a list of items in Column A, and in the other columns (each column is named after a different user email) i want to use a true/false (or yes/no) approach to indicate which items of Column A are related to each user. The objective is to create a dropdown/combobox input in an app which, depending on the current user (recognised by his/her email address at login) shows a filtered) list of items based on that table.

    Is it possible to do this with just one single table?
    Many thanks!

  • Re: Select table based on current user.

    Hi @Anonymous :

    If you still have any question,please don't hesitate to let me know.

    Best Regards,
    Bof

  • Re: Select table based on current user.

    Sorry for the late response, been away from work a few days.

    the table have the same structure yeah.

    originally i wanted the program to just read the current user using the program, but a simple select user drop down is also fine.

    ill try and find some more indepth information on how to work with the gallery.

  • Verified answer
    Re: Select table based on current user.

    Hi @Anonymous :

    Could you tell me:

    • Do you want to choose different data sources based on current users?
    • Do your data tables have the same data structure?

    I assmue they have the same data structure.

    It can be easily achieved using If or Switch.For example:

    Solution1:Set the gallery's items property to:

     

    Switch(
     User().FullName,
     "User1",
     Table1,
     "User2",
     Table2, 
     "User3",
     Table3,
     "User4",
     Table4
    )

     

    Solution2:Set the gallery's items property to:

     

    If(
     User().FullName="User1",
     Table1,
     User().FullName="User2",
     Table2, 
     User().FullName="User3",
     Table3,
     User().FullName="User4",
     Table4
    )

     

    Best Regards,

    Bof

  • eka24 Profile Picture
    eka24 20,921 on at
    Re: Select table based on current user.

    Good start. But I suggest you put all users in Column of the table. So instead of multiple Tables, have only one Table as your main table. Then within that table user one Column where all the User names or email will be entered.

     

    Then when you connect the Table to a Gallery, you can Filter to show the record for that particular user using;

     

    Filter (Table1, Email=User().Email)

     

    ------------

    If you like this post, give a Thumbs up. Where it solved your request, Mark it as a Solution to enable other users find it.

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,304

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,703

Leaderboard