cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
QuestionTime
Frequent Visitor

How to create a filter to limit what data each user sees?

I wish to make a Power App for my team that filters data so each team member can only see the data that they are responsible for. I created a username and password for each user in an SQL Server. The user will then use their login info on the first page of the Power Apps; after successful login, they will navigate to second screen that shows only their data. 

 

Currently I have a functional login screen. My problem is that my filter on the next screen does not filter data based on the login info from screen 1 of the Power App. 

 

This is my formula: Filter('SQL_Table', SQL_Column = User().Email)

I am trying to alter the filter formula so it can filter data based off of the username that was inputted on the previous screen. Is this possible? I am assuming I have to remove 'Email' and replace it with a reference to the username text input from screen 1. Can I do this on Power Apps?

1 ACCEPTED SOLUTION

Accepted Solutions

Okey so here is how you can do this.

After the user is successfully logging in you can set a variable Set(Username,THE USERNAME TEXT FILED.Text)

Then your filter will be like

Filter('SQL_Table', SQL_Column = Username)

 

Please click Accept as Solution if it resolved your problem or give it a Thumbs Up if it helped you in anyway this will allow other people to search correct solutions effectively.

Thanks,

Rahber

View solution in original post

5 REPLIES 5
Rahber
Super User II
Super User II

What is the column in SQL storing? The username or the email?

You will only be able to filter the records from SQL if they have a Email or username stored in the column

 

Please click Accept as Solution if it resolved your problem or give it a Thumbs Up if it helped you in anyway this will allow other people to search correct solutions effectively.

Thanks,

Rahber

The SQL column is username.

Okey so here is how you can do this.

After the user is successfully logging in you can set a variable Set(Username,THE USERNAME TEXT FILED.Text)

Then your filter will be like

Filter('SQL_Table', SQL_Column = Username)

 

Please click Accept as Solution if it resolved your problem or give it a Thumbs Up if it helped you in anyway this will allow other people to search correct solutions effectively.

Thanks,

Rahber

View solution in original post

Thank you.

Where do I create this variable exactly?

Also, you wrote 'THE USERNAME TEXT FILLED' to put in the variable formula; does this mean the location of where the username was inputted? ex. Set(Username,TextInput1.Text)

Yes you will use the text field name where the username was entered on the login screen.

Use this formula on the submit button of your login screen.

Helpful resources

Announcements
PA User Group

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (4,025)