web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Apps
Unanswered

If Filter function

(0) ShareShare
ReportReport
Posted on by 58

Hello,

 

I am very new to power apps and am having difficulty with a function.

I want to use an if statement to compare the current user to a list I have established.  If the user is on the list and active, then I want to navigate to another screen.  If the current user is not either not on the list, or not active, I have a label I want to become visible.  Looking at other posts, I have set my screen to OnVisible = UpdateContext({cVisible: false}), and my Apps OnStart to Set(currentUser, User())

I am getting several errors on my formula, which I am still having trouble deciphering.

Any help would be very much appreciated.

Categories:
I have the same question (0)
  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Cathleen307 

    Can you provide some of the formulas you mention have errors and what those errors are?

  • Cathleen307 Profile Picture
    58 on at

    Hello Randy,

     

    I'm trying to simplify the function so that I get the first part to work, which it still isn't.  After I get the first part, I will try to add the second condition, but below is the function I am starting with.

     

    If(Filter('Process Diary Quality Approval List', ApproverText) = CurrentUser.FullName , cVisible=true, cVisible=false)

     

    My current failure mode is Incompatible types for comparison: table, text.

     

    I really appreciate you responding so quickly.

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Cathleen307 

    Yes, you are trying to compare an entire table (returned from Filter) with a text value - FullName.  No can do in PowerApps!  Also, you are trying to set a variable with a programmatic syntax (cVlisible = true).  You cannot do this in PowerApps as PowerApps is NOT a development platform. You need to perform functions for that.  OR have your controls derive from other control values that have already evaluated their values.

     

    I would suggest that you centralize this to a global variable for the app, as my guess is, you will want to reference this often.

    So, in your OnStart:

    Set(glbIsApprover, LookUp('Process Diary Quality Approval List', ApproverText = CurrentUser.FullName, true))

    This will set the glbIsApprover to true if the record exists.  

    Also, you might consider avoiding using FullName as the identifier - if you have a large organization, this can cause problems as two or more people can have the same full name - email is more reliable.

     

    Not for your label, you would set the Visible property to : !glbIsApprover

    And, your StartScreen property for the App can be:

       If(glbIsApprover, approverScreenName, nonApproverScreenName)

     

     

  • Cathleen307 Profile Picture
    58 on at

    Hello again Randy,

    That part of the app is working properly, thank you for the reply.  Now for the rub.  I have different levels of approval based upon the current user, and corresponding tables for Quality approvers, Manaufacturing approvers, and Maintenance approvers.  How do I specify the types of approvers based upon which list they belong to?  

    Then..will wait until I have then portion worked out.

    Thanks again for your support.

  • Verified answer
    RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Cathleen307 

    Easiest thing to do then is combine it all together in the variable.

    Ex.

    Set(glbApprover, 
     {Quality: LookUp('Process Diary Quality Approval List', ApproverText = CurrentUser.FullName, true),
     Manufacture: LookUp(ManufacturingApproversListName, ApproverText = CurrentUser.FullName, true),
     Maintenance: LookUp(MaintenanceApproverListName, ApproverText = CurrentUser.FullName, true)
     }
    )

    This makes the variable glbApprover a record that has three columns with their corresponding value.

     

    So, if you want, for example, a label to be visible for Manufacture Approvers only, then set the Visible property to: glbApprover.Manunfacture

    Likewise for others, just reference that column of the glbApprover variable.  It will already be true or false based on those lookups and will be available throughout the app to reference.

  • Cathleen307 Profile Picture
    58 on at

    I followed the instruction below, and put the following function in the StartScreen:

    Cathleen307_1-1639488555853.png

     

    And now I get the following error:

    Cathleen307_0-1639488489911.png

    Help please.

  • RandyHayes Profile Picture
    76,297 Super User 2024 Season 1 on at

    @Cathleen307 

    As mentioned, that is for your OnStart action of the app, not the StartScreen.

    I mentioned it in Post #4, but should have reemphasized that in the last post.

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard