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

Community site session details

Session Id : mLYHdnYpGx8vjOdeBF+9DW
Power Apps - Building Power Apps
Answered

Dynamic gallery filter plus Or statement

Like (0) ShareShare
ReportReport
Posted on 23 Oct 2023 19:34:30 by 134

hi there! thanks now for any input. I have a gallery that is currently filtered as such:

 

 

Sort(
Filter(
CIRFacilityLocal,
Or(
varSearch2 in 'Offender Number',
varSearch2 in 'Give a brief description of the incident.',
varSearch2 in 'CIR Number'
)
),
Created,
SortOrder.Ascending
)

 

But I now need it to filter with a dynamic user as well. I have a table in my OnStart that looks like this:

colRedirect,
Table(
{
Facility_Location: "AMF",
Role: "Secretary",
Screen: SecretaryHome,
Message: "Welcome, Warden's Office!",
Key: "656510"
}

and i need the gallery to omit items from a yes/no column based on the "Role" they are in the table and still be able to use the search function it already has.

I need anyone whos Role says "Facility" to not see anything marked YES in the Y/N column Confidential (ThisItem.'Confidential?').

 

Is this possible to do in the same gallery or should i redirect this group to a different page and do a gallery with a pre-filtered collection?

I have the same question (0)
  • BHaapi Profile Picture
    134 on 26 Oct 2023 at 13:14:41
    Re: Dynamic gallery filter plus Or statement

    it worked! as soon as i pasted i saw the missing one too. so sorry but thank you so much! i really appreciate it!

  • v-jefferni Profile Picture
    on 26 Oct 2023 at 01:35:19
    Re: Dynamic gallery filter plus Or statement

    Hi @BHaapi ,

     

    Sorry, I was missing a coma in that formula. Have edited it in original reply, please try it again.

     

    Best regards,

  • BHaapi Profile Picture
    134 on 25 Oct 2023 at 13:49:59
    Re: Dynamic gallery filter plus Or statement

    I was able to update the variable, not exactly how you had it because it didnt seem to like that, so i did a Set(varRole, locResult.Role) on their visible property of their homepage. I was able to prove it updated when i added a textbox with varRole. im now getting an opperand error and cant seem to figure out where it is. its pulling red lines for the entire With function:

    With(
    {wFilter: Filter(CIRFacilityLocal, If(varRole = "Facility", 'Confidential?'= false))},
    Sort(
    Filter(
    wFilter
    Or(
    varSearch2 in 'Offender Number',
    varSearch2 in 'Give a brief description of the incident.',
    varSearch2 in 'CIR Number'
    )
    ),
    Created,
    SortOrder.Ascending
    )
    )

     

    after removing the sort i was able to narrow it down to the Filter wFilter area. the columns for the variable search isnt linking to the CIRFacilityLocal anymore. I went throught to type them from scratch and as i scrolled through the suggestions i noted the column names werent there anymore:

    BHaapi_0-1698241742999.png

    any ideas on this? I'd like to still have sort order, of course, i just removed it to see where the real problem could be.

  • Verified answer
    v-jefferni Profile Picture
    on 25 Oct 2023 at 03:23:25
    Re: Dynamic gallery filter plus Or statement

    Hi @BHaapi ,

     

    Your idea that creating another variable is almost close. Actually, you already have the variable locResult where includes Screen and Role. So, please modify the formula first:

     

    //lookup which user type from table
    UpdateContext(
    {
    locResult: LookUp(
    colRedirect,
    Key = varPassword
    )
    }
    );
    //redirect and get the role
    Navigate(
    locResult.Screen,
    {varRole:locResult.Role}
    ScreenTransition.Cover
    );

     

     

    Then on the Gallery screen, use the variable varRole to filter:

     

    With(
     {wFilter: Filter(CIRFacilityLocal, If(varRole = "Facility", Y/N = false, true))},
     Sort(
     Filter(
     wFilter,
     Or(
     varSearch2 in 'Offender Number',
     varSearch2 in 'Give a brief description of the incident.',
     varSearch2 in 'CIR Number'
     )
     ),
     Created,
     SortOrder.Ascending
     )
    )

     

     

    Best regards,

  • BHaapi Profile Picture
    134 on 24 Oct 2023 at 12:41:43
    Re: Dynamic gallery filter plus Or statement

    So i currently use the table (OnStart) to dynamically navigate users to the correct homepage, out of several. that is linked to their passcode at the login screen. I call that locResult and was hoping there would be a way to use a similar dynamic lookup from login to filter the gallery, as the same table also has other information in it. below is the current homepage navigation im using, and was wondering if it could somehow be tied into the gallery to filter out the confidential items.

     

    //lookup which user type from table
    UpdateContext(
    {
    locResult: LookUp(
    colRedirect,
    Key = varPassword
    )
    }
    );
    //redirect
    Navigate(
    locResult.Screen,
    ScreenTransition.Cover
    );

     

    I was thinking i could create another variable at the login page that would be referenced in the same manner, such as the above equation. but instead of referencing the screen, it would reference the "role" from the table in the variable instead.

     

    Boy i hope that makes sense. im sorry! ive been trying to figure this out for a while and im not sure im making sense

  • v-jefferni Profile Picture
    on 24 Oct 2023 at 07:00:11
    Re: Dynamic gallery filter plus Or statement

    Hi @BHaapi ,

     

    Could you please share more details about your scenario? How would you compare the user and their roles with that table where doesn't include any user info? 

     

    Anyway, you can edit your initial formula as below, to apply more conditions including the comparison of roles:

    With(
     {wFilter: Filter(CIRFacilityLocal, If(ConditionToCheckUserRole, Y/N = false, true))},
     Sort(
     Filter(
     wFilter
     Or(
     varSearch2 in 'Offender Number',
     varSearch2 in 'Give a brief description of the incident.',
     varSearch2 in 'CIR Number'
     )
     ),
     Created,
     SortOrder.Ascending
     )
    )

     

    Generally, the condition would look like LookUp(...).Role = "Facility". But since I don't know where you save user info/roles, I'm not able to provide more detailed formula.

     

    Best regards,

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

MS.Ragavendar – Community Spotlight

We are honored to recognize Ragavendar Swaminatha Subramanian as our September…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 892 Most Valuable Professional

#2
Power Apps 1919 Profile Picture

Power Apps 1919 356

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 310 Super User 2025 Season 2

Last 30 days Overall leaderboard
Loading complete