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 / Filter a datatable by ...
Power Apps
Answered

Filter a datatable by user?

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi,

 

I connected my PowerApp to SQL Server and used a datatable to represent the table I have in SQL Server. This datatable/table has about 1,000 records. The first column is "name", which represents an employees' name. 

 

Is it possible to filter this datatable to only show the current users' record? For instance, let's say Barry Manowhich launched the PowerApp and navigates to the screen with the datatable. Can I filter it so that it'll only show information related to Barry Manowhich?

So far, I used a Button and set the OnSelect = Set(_currentUser,User().FullName)

Then on my datatable, I set Items = Filter(Search('[dbo].[CV_V_CURR_EMP_BALANCES]'), name=_currentUser)

On the OnStart of the App, I put in Set(_currentUser,User().FullName)

 

I'm getting several errors, can anyone point why I'm getting these errors?

 

Thank you

Categories:
I have the same question (0)
  • timl Profile Picture
    36,780 Super User 2026 Season 1 on at

    Hi @Anonymous 

    If you just apply Filter function in the Items property of your datatable, that should solve the problem.

    Filter('[dbo].[CV_V_CURR_EMP_BALANCES]', name=_currentUser)

    If not, can you post the errors that you're receiving?

     

     

     

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @timl 

     

    If I take out the Search function, the formula doesn't recognize the "name" column with the green outline. 

    When I inserted the formula you provided, the errors are gone  but I receive a "we ddin't find any data to show at this time" message...

     

    My initial thought is that the name column in my datatable is "Last Name, First Name". If I use the FullName function, does it list as "First Name, Last Name"?

     

    Also, the name's in the datatable aren't exactly uniform. For example, I have an Plumlee, Marshall, G. and a different record has Lillard, Damian, Gerald. Could the formatting be the issue?

     

  • timl Profile Picture
    36,780 Super User 2026 Season 1 on at

    Hi @Anonymous 

    User().FullName will return the name in the format "FirstName LastName". Unless the names in your data table match this format, this technique won't return the records that you expect.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Check first if the name return from the User() has the same format as your column. Just put the formulas in the Text property of a label to see what returns.

     

    In my organisation User().FullName returns "FirstName LastName", as an alternative I tried the following function: Office365Users.MyProfile().DisplayName   in my case this one returns "LastName, FirstName" format. To use this last function you need to add the Office365 connection first.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    Hi @timl @Anonymous 

     

    I also wanted to mention, when I declare my _currentUser variable on the OnStart screen, I receive 2 errors: One under "Set" which says Expected Operator. We expect an opersator such as +,*, or & ...... no operator between them. The other error I receive is under the comma is unexpected characters. The formula contains 'ParenClose' where 'Comma' is expected and Characters are used in the formula in an unexpected way.

     

     

  • timl Profile Picture
    36,780 Super User 2026 Season 1 on at

    Hi @Anonymous 

    That's strange because what you've entered in the OnStart is valid syntax. Could there possibly be some other text or characters after your call to the Set function?

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    If you are not going to use the name variable many times, maybe it is better to add the name call on the filter function

     

    Filter('[dbo].[CV_V_CURR_EMP_BALANCES]', name=Office365Users.MyProfile().DisplayName)

     

  • Verified answer
    timl Profile Picture
    36,780 Super User 2026 Season 1 on at

    Hi @Anonymous 

    Just for info, I would always recommend that you always store a value such as Office365Users.MyProfile().DisplayName in a variable, particularly if you want to use it with a function such as Filter.

    The reason for this is that calling Office365Users inside a Filter will make queries non-delegable.

    https://powerusers.microsoft.com/t5/General-Discussion/Delegation-not-working-as-documented-with-SQL-Server/m-p/239275#M70162

     

    When PowerApps executes this type of query, it'll call Office365Users for each row that it returns. There is a 'rate limit' to calling Office365Users, and it's possible to exceed this limit under high load.

     

    https://powerusers.microsoft.com/t5/General-Discussion/rate-limit-is-exceeded-using-Office365Users-UserProfile/td-p/44900

    Hope that's of some use to you.

  • Community Power Platform Member Profile Picture
    Microsoft Employee on at

    good point...thank you! 

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the March Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 547

#2
WarrenBelz Profile Picture

WarrenBelz 444 Most Valuable Professional

#3
Valantis Profile Picture

Valantis 322

Last 30 days Overall leaderboard