cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
mark_daquin
Level: Power Up

Filtering a gallery (Share Point list) by Created By

Hi - I've created a simple Time Tracking app (list 'Time Tracker')and on the BrowseScreen1 I want to place a button that will filter (boolean) between all entries and my entries. I have a column in my list called Created By with is the author of the line item. 

 

I placed an icon at the top of my BrowseScreen1 (button) and placed the following fx for OnSelect of the button to be

UpdateContext({ myTimeOnly: !myTimeOnly, CurrentUser:User().Email });
If ( myTimeOnly, Filter('Time Tracker', 'Created By'.Email=CurrentUser ),'Time Tracker')

 

I am pretty new to PowerApps so any help here woudl be great.

 

Thanks,

Mark

1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Filtering a gallery (Share Point list) by Created By

@mark_daquin 

You're close!!

The variable updates (UpdateContext) on the button OnSelect are fine.

However your formula for the Filter needs to go on your Gallery.

Set the Items property to the following:

Filter('Time Tracker', If(myTimeOnly, 'Created By'.Email=CurrentUser, true))

This will filter your gallery when the myTimeOnly is true.  Otherwise it will filter against true (all records).

 

I hope that is helpful for you.

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

7 REPLIES 7
Super User
Super User

Re: Filtering a gallery (Share Point list) by Created By

@mark_daquin 

You're close!!

The variable updates (UpdateContext) on the button OnSelect are fine.

However your formula for the Filter needs to go on your Gallery.

Set the Items property to the following:

Filter('Time Tracker', If(myTimeOnly, 'Created By'.Email=CurrentUser, true))

This will filter your gallery when the myTimeOnly is true.  Otherwise it will filter against true (all records).

 

I hope that is helpful for you.

 

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

View solution in original post

mark_daquin
Level: Power Up

Re: Filtering a gallery (Share Point list) by Created By

Hi Randy,

 

Thanks it works. The only thing is that I get a delegation warning the blue wavy line is under .Email - is this something I should be concerned about. I don't expect a large number of users, but I am expecting a large number of entries.

 

Thanks,

Mark

Super User
Super User

Re: Filtering a gallery (Share Point list) by Created By

@mark_daquin 

So definitely consider that issue...when you say large number of records, are you talking over 2000?

If so, you might want to prepare your data for delegation.

In this case the way to do that is to have an additional text column in your list.  In that column, you would have, either Flow or PowerApps update it with the text version of the User - Usually the email address.

Then, you can filter with a Filter(myDataSource, StartsWith(theTextUserColumn, userEmailAddress)) 

This is something that can be delegated.

But only consider this if you feel your data source will grow beyond 2000.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
mark_daquin
Level: Power Up

Re: Filtering a gallery (Share Point list) by Created By

Hi Randy,

 

Is this 2000 records per user or total? Also, if you do not do it now will it be an issue if you decide you need to do it later?

 

Thanks,

Mark

Super User
Super User

Re: Filtering a gallery (Share Point list) by Created By

@mark_daquin 

That would be 2000 total in the list.  

Not so much that it will be an issue to change it later - the question becomes...at what cost?  

Do you do it when the App hits that limit and then breaks and have the pressure of fixing it then?  Or, do you just plan on it now (if you know it's going to hit it eventually) and be done with it?  Or, do you do "version 1" and then fix it in "version 2" before it hits the limit?

You would know your data and its growth potential better, so just choose from that.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.
mark_daquin
Level: Power Up

Re: Filtering a gallery (Share Point list) by Created By

Hi Randy,

 

So, that I make sure I understand the concept of data delegation. Basically, the way I have it set up now is that the app is doing a lookup of the email and user which takes a lot more computation then if that email is converted to text and used to sort that way. Is the correct way of looking at it?

 

Thanks,

Mark

Super User
Super User

Re: Filtering a gallery (Share Point list) by Created By

@mark_daquin 

There are two aspects to deal with, one is record limit and one is delegation.  

Record limit will "limit" the number of records you can retrieve from a datasource in ONE call (max is 2000).

Delegation is the ability to "push" a query to the datasource to "filter" the information before it is sent back - thus limiting the number of records returned to just what you want.

SOME functions and operators can be delegated to the datasource (in this case, you want to consult the SharePoint Connector Reference for those functions and operators).

IF a function or operator CAN be delegated, then you will get only the results based on that statement BUT still limited to the maximum records of 2000.  If that becomes an issue than you would want to take a serious look at why your query would return so much data and what you would need it for anyway.

IF a function or operator CANNOT be delegated, then PowerApps has to pull down all the records and do the function or operator locally.  There you will always be limited by the maximum records.

If you have a list of 2001 records and 2001 is one that matches the user name that you are trying to filter for, and you try to do it against the 'Created By'.Email - the query cannot be delegated (that type of column is considered a Complex Type and cannot support any form of delegation...even if the function or operator does) - you will never get it, and your results will be inaccurate.

 

In your case we talked about using StartsWith - that is because (if you look at the connector reference) that function CAN be delegated AND, in this case, we have created a Text Column with the user information - which is NOT a complex type.  So, in the example above.  You would get result 2001 in your formula because you are now filtering with a column that can be delegated (simple type) and a function that can be delegated (StartsWith).

 

NOW...with all that said - maximum records always applies.  So, taking the example above - if ALL of your records had the same user email, you would STILL only get 2000.

 

I hope that helps clear it up some for you.

 

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up. Solved your problem? - Click on Accept as Solution. Others seeking the same answers will be happy you did.

Helpful resources

Announcements
thirdimage

Power Automate Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

sixthImage

Power Platform World Tour

Find out where you can attend!

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

fifthimage

Microsoft Learn

Learn how to build the business apps that you need.

Top Kudoed Authors (Last 30 Days)
Users online (5,813)