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

Filter Dropdown by Current User?

I have a PowerApp with a dropdown. I would like the dropdown to show just the records that are attached to the current users email from a sharepoint list that feeds the dropdown. The table that feeds the dropdown has two fields (School and Email). I would like the current users email to filter the table to just the records with the users email so they can select items unrelated to them. I cant seem to get this to work properly however. Anyone know what I am doing wrong? The table is a Sharepoint list and both values should be text.

 

Filter(T_Schools_FY20.School,Lower(User().Email) in T_Schools_FY20.PM_Email)

 

4 REPLIES 4
krishnags
Responsive Resident
Responsive Resident

@cbischel  try 

Set(varCrntUserEmail, Lower(User().Email)) on AppStart or Screen OnVisible....

 

Filter(T_Schools_FY20.School,varCrntUserEmail = T_Schools_FY20.PM_Email)

 

@krishnags , Using that formula results in the following error:

 

"Warning: The columns produced by this rule are all nested tables and/or records, however the property expects at least some columns of simple values (such as text, or numbers)."

 

Thanks for the help.

wyotim
Resident Rockstar
Resident Rockstar

Hi @cbischel, you look like you are about there! Perhaps try this instead:

Filter(
    T_Schools_FY20,
    Lower(User().Email) = PM_Email
)

Just to explain what I changed, the data source (T_Schools_FY20) is what you are filtering so you don't need to specify the field you want in that part. Then for the second part (the formula section), the data source is already defined in the previous part so you can just list the field(s) you want to filter against (PM_Email) and by what value (those equal to User().Email in lowercase). For the record, you could use 'in' like you did instead of the '=' as I did; this could be the better way in cases where the data isn't totally clean (like having spaces before or after the email address for instance) as it looks for a match within some text instead of an exact match to the text.

 

Then in the dropdown, you can specify the field to display which I would guess is School. This is done in the Value property of the dropdown. 

 

I hope that helps and solves your issue but if not feel free to let me know what isn't working and I'll happily follow up!

wyotim
Resident Rockstar
Resident Rockstar

Looks like I posted a bit late, but I agree with @krishnags on using a variable for User().Email. This makes it so Power Apps doesn't make the call to check the email every time that reference is used. Chances are it hasn't changed since the user opened the app!

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,443)