cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ArmanGabd
Helper I
Helper I

PowerApp Filter issue

Hello,

 

I am facing with one problem in my app. Trying to create an app within our environment.

What I have right now, List of created tickets connected to excel file. 

Users should see their own tickets and admins as me, see all tickets.

But template of app already has Filter function in Items property.

I even couldnt add sort function because excel sorting it in ascending order when i want it to be sorted descending(newest on top).

Please help.

 

Item property of TicketsGallery

If(type="All",Tickets,If(type="Tickets older than 3 days",Filter(Tickets,DateCreated<>datetype&&DateCreated<>Text(Today()),DateCreated<>Text(DateAdd(Today(),-2)),DateCreated<>Text(DateAdd(Today(),-1))||DateClosed<>datetype&&DateClosed<>Text(Today()),DateClosed<>Text(DateAdd(Today(),-2)),DateClosed<>Text(DateAdd(Today(),-1))),If(type="Tickets opened today",Filter(Tickets,datetype in DateCreated),If(type="Tickets closed today",Filter(Tickets,datetype in DateClosed),Filter(Tickets,type in Status)))))

1 ACCEPTED SOLUTION

Accepted Solutions

@ArmanGabd ,

Try this

Sort(
   If(
      type = "All",
      Tickets,
      If(
         type = "Tickets older than 3 days",
         Filter(
            Tickets,
            DateCreated <> datetype && DateCreated <> Text(Today()),
            DateCreated <> Text(
               DateAdd(
                  Today(),
                  -2
               )
            ),
            DateCreated <> Text(
               DateAdd(
                  Today(),
                  -1
               )
            ) || DateClosed <> datetype && DateClosed <> Text(Today()),
            DateClosed <> Text(
               DateAdd(
                  Today(),
                  -2
               )
            ),
            DateClosed <> Text(
               DateAdd(
                  Today(),
                  -1
               )
            )
        ),
        If(
            type = "Tickets opened today",
            Filter(
                Tickets,
                datetype in DateCreated
            ),
            If(
               type = "Tickets closed today",
               Filter(
                  Tickets,
                  datetype in DateClosed
               ),
               Filter(
                  Tickets,
                  type in Status
               )
            )
         )
      )
   ),
   'Created',
   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.

View solution in original post

4 REPLIES 4
WarrenBelz
Super User
Super User

HI @ArmanGabd ,

You simply need to "wrap" the filter around your code. I would do it for you if I could parse your code correctly ( I seem to have an extra bracket) Please use "Format Text" and paste in in a code box (the "</>" icon after you select the "three dots" menu at the top of your forum post). You might also take a few minutes to watch this video from Shane Young.

If(
    type = "All",
    Tickets,
    If(
        type = "Tickets older than 3 days",
        Filter(
            Tickets,
            DateCreated <> datetype && DateCreated <> Text(Today()),
            DateCreated <> Text(
                DateAdd(
                    Today(),
                    -2
                )
            ),
            DateCreated <> Text(
                DateAdd(
                    Today(),
                    -1
                )
            ) || DateClosed <> datetype && DateClosed <> Text(Today()),
            DateClosed <> Text(
                DateAdd(
                    Today(),
                    -2
                )
            ),
            DateClosed <> Text(
                DateAdd(
                    Today(),
                    -1
                )
            )
        ),
        If(
            type = "Tickets opened today",
            Filter(
                Tickets,
                datetype in DateCreated
            ),
            If(
                type = "Tickets closed today",
                Filter(
                    Tickets,
                    datetype in DateClosed
                ),
                Filter(
                    Tickets,
                    type in Status
                )
            )
        )
    )
)

Sorry, first time I am leaving this kind of issue in my life)

@ArmanGabd ,

Try this

Sort(
   If(
      type = "All",
      Tickets,
      If(
         type = "Tickets older than 3 days",
         Filter(
            Tickets,
            DateCreated <> datetype && DateCreated <> Text(Today()),
            DateCreated <> Text(
               DateAdd(
                  Today(),
                  -2
               )
            ),
            DateCreated <> Text(
               DateAdd(
                  Today(),
                  -1
               )
            ) || DateClosed <> datetype && DateClosed <> Text(Today()),
            DateClosed <> Text(
               DateAdd(
                  Today(),
                  -2
               )
            ),
            DateClosed <> Text(
               DateAdd(
                  Today(),
                  -1
               )
            )
        ),
        If(
            type = "Tickets opened today",
            Filter(
                Tickets,
                datetype in DateCreated
            ),
            If(
               type = "Tickets closed today",
               Filter(
                  Tickets,
                  datetype in DateClosed
               ),
               Filter(
                  Tickets,
                  type in Status
               )
            )
         )
      )
   ),
   'Created',
   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.

View solution in original post

ArmanGabd
Helper I
Helper I

Thank you very much))

Now it works how i wanted, but I need to manipulate numbers of ID. 

Now it sorts like this:

9

8

7

...

2

1

10

11

12

 

Anyways thanks for help.

Helpful resources

Announcements
UG GA Amplification 768x460.png

Launching new user group features

Learn how to create your own user groups today!

Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

M365 768x460.jpg

Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (2,701)