cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Super User III
Super User III

Re: Filter a gallery based on users

OK @TimoMigchielsen Try the below

Sort(
   Search(
      If(
         selectedStatus = "All" || gblIsAdmin,
         MancoTabel,
         Filter(
            MancoTabel,
            IsBlank(selectedStatus) || Title = selectedStatus
         )
      ),
      TekstZoekVeld.Text,
      "Verzender"
   ),
   Datum,
   If(
      SortDescending1,
      Ascending,
      Descending
   )
)

You will probably now understand why I needed your logic.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Highlighted
Post Prodigy
Post Prodigy

Re: Filter a gallery based on users

Hello! 

Thank you so much for your answer. However, I see you've done "Verzender" at the textsearchbox but I want it to stay like this: 

TextSearchBox1.Text,
"Ordernummer",
"Verzender",
"Deelorder",
"Extern",
"Product",
"Intern",
"Deelorder",
"Tekeningnummer",
"Omschrijving",
"Status"

I want the whole gallery to automatically filter on their fullname Verzender. Not that they are able to type it in the searchbox. It is a little hard to explain but I hope you know what I mean @WarrenBelz 

And where does the "title" come from?

Highlighted
Super User III
Super User III

Re: Filter a gallery based on users

Thanks @TimoMigchielsen ,

We are almost there, but I really need to understand one thing that is not clear to me. First, can we go "from the outside in" so I know which bits are correct

  1. The whole gallery is sorted by Datum (I assume date), either ascending or descending
    Then I have an icon to sort ascending and descending. I am using this so I can quickly switch between the dates. Quickly change between latest and first tickets.
  2. You are searching with input from TekstZoekVeld.Text in the field - do you want to search ALL of these fields - see below
    I then have a search field where I can search for all of these things below "TekstZoekVeld.Text". 
  3. User info now included below.
    What am I trying to do is, Filter this whole gallery by the current user of the application. Because I am making the application right now, I am the only one in that list in the database but there will be many more than just me when I bring out the application. So basically whenever the application starts up, I want it to save the full name of the current user.

  4. Selected Status can be "All" or something else. All shows all records or the data is filtered by the Title having the Selected Status.
    We are basically sorting the gallery with a selectedstatus. My application is a ticket system where people can submit a ticket. Each ticket has its own status. Currently I have 4 different statussus. For this I am using a switch.
Sort(
   Filter(
      If(
         selectedStatus = "All" || gblIsAdmin,
         MancoTabel,
         Filter(
            MancoTabel,
            IsBlank(selectedStatus) || Title = selectedStatus &&
            VerZender = User().FullName
         )
      ),
      TekstZoekVeld.Text in "Verzender" ||
      TekstZoekVeld.Text in "OrderNummer" ||
      TekstZoekVeld.Text in "Deelorder" ||
      TekstZoekVeld.Text in "Extern" ||
      TekstZoekVeld.Text in "Product" ||
      TekstZoekVeld.Text in "Intern" ||
      TekstZoekVeld.Text in "Tekeningnummer" ||
      TekstZoekVeld.Text in "Omschrivjving" ||
      TekstZoekVeld.Text in "Status"
   ),
   Datum,
   If(
      SortDescending1,
      Ascending,
      Descending
   )
)

You will have to look at valid values as I cannot see your data.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Highlighted
Post Prodigy
Post Prodigy

Re: Filter a gallery based on users

Thank you for your response. We are indeed very close. The only thing that is not working is the "title" @WarrenBelz 

Let me make all of this more clear.

I have a ticket system. Looks like this: 
https://gyazo.com/5866dd566c2857adb9def4dd99626f50

You can see the code of a textfield. This textfield is basically filled with the users fullname as you can see in the screenshot. This information is stored in here:

Mancotabel -> Verzender

Currently this is my code of my BrowseGallery of my tickets. I am currently able to filter on 4 different statusses. 

-All
-Open
-Verwerkt in Ridder
-In behandeling

Now what I want:

Since I will store the FullName of the user. I want them only to be able to see the own tickets that they have created. Now I have a column with admins that are stored under here:

Admins -> Administrators

This information above is stored by hand. This is just the users email adress. I want these admins to be able to see everything. 

So basically, we need to filter the whole gallery. If their email is in Admins -> Administrators, they get to see all the tickets. If their email is not in there, they will only see the tickets which ticket with Verzender is equal to the users fullname. 

The code below fully works and shows all the tickets.

 

SortByColumns(
      Search(
         Switch(
            selectedStatus,
            "All",
            MancoTabel,
            Filter(
               MancoTabel, 
               IsBlank(selectedStatus) ||
               Status = selectedStatus
            )
         ), 
         TekstZoekVeld.Text, 
         "Ordernummer",
         "Verzender",
         "Deelorder", 
         "Extern", 
         "Product", 
         "Intern", 
         "Deelorder", 
         "Tekeningnummer", 
         "Omschrijving",
         "Status"
      ), 
      "Datum", 
      If(
         SortDescending1, 
         Ascending, 
        Descending
      )
   )

 



Highlighted
Super User III
Super User III

Re: Filter a gallery based on users

Ok @TimoMigchielsen ,

Back to your code structure - apologies if I structure things differently - it is just the way I get things to work.

You now need if isGblAdmin is true to see ALL records or any other user to see only their own?

You will have to check the brackets etc, but I am sure you will see the logic flow.

SortByColumns(
   Search(
       If(
         isGblAdmin,
         MancoTbl,  
         Filter(
            MancoTabel,
            Verzender = User().Email &&
            If(
               selectedStatus <> "All",
               IsBlank(selectedStatus) ||
               Status = selectedStatus
            )
         )
      ), 
      TekstZoekVeld.Text, 
      "Ordernummer",
      "Verzender",
      "Deelorder", 
      "Extern", 
      "Product", 
      "Intern", 
      "Deelorder", 
      "Tekeningnummer", 
      "Omschrijving",
      "Status"
   ), 
   "Datum", 
   If(
      SortDescending1, 
      Ascending, 
     Descending
   )
)

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

 

Highlighted
Post Prodigy
Post Prodigy

Re: Filter a gallery based on users

I do not get any errors using your code, so I am assuming it will work. 

However: I get this error trying to submit a ticket. Do you maybe know what could be causing this issue?

https://gyazo.com/b01247f0297cb7e8ef6cf196cd1f246b

I have looked inside my excel file on the browser, the tickets are there. Whenever I open the app function I don't see the tickets. Kind of strange...

@WarrenBelz 

Highlighted
Super User III
Super User III

Re: Filter a gallery based on users

HI @TimoMigchielsen ,

This is a different subject - the one we have solved was filtering a gallery.

If you accept this one and tag me with your Patch code of the structure you are submitting, I will look at it.

 

Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

Highlighted
Post Prodigy
Post Prodigy

Re: Filter a gallery based on users

 
Highlighted
Post Prodigy
Post Prodigy

Re: Filter a gallery based on users

I have tried the code and it works for admins (I think).  @WarrenBelz 

Now I have removed my email from the admin list and I can't see any tickets at all. Although my full name is inside of some tickets. What could be the issue? 

 

This is the code, I have changed this part: Verzender = User().Email to User().Fullname, as Verzender variabele is saved as the fullname when they create a ticket.

 

SortByColumns(
   Search(
       If(
         gblIsAdmin,
         MancoTabel,  
         Filter(
            MancoTabel,
            Verzender = User().FullName &&
            If(
               selectedStatus <> "All",
               IsBlank(selectedStatus) ||
               Status = selectedStatus
            )
         )
      ), 
      TekstZoekVeld.Text, 
      "Ordernummer",
      "Verzender",
      "Deelorder", 
      "Extern", 
      "Product", 
      "Intern", 
      "Deelorder", 
      "Tekeningnummer", 
      "Omschrijving",
      "Status"
   ), 
   "Datum", 
   If(
      SortDescending1, 
      Ascending, 
     Descending
   )
)

 


 

I have now figured out that only the "All" function is not working. The other filters are working perfectly.

Highlighted
Post Prodigy
Post Prodigy

Re: Filter a gallery based on users

@WarrenBelz 

Do you have any idea why the "all" function is not working anymore? The rest works perfectly now, thanks again!

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Watch Now

Experience what’s next for Power Apps

See the latest Power Apps innovations, updates, and demos from the Microsoft Business Applications Launch Event.

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

secondImage

Power Platform 2020 release wave 2 plan

Features releasing from October 2020 through March 2021

Top Solution Authors
Top Kudoed Authors
Users online (7,440)