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 III
Super User III

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
PA_User Group Leader_768x460.jpg

Manage your user group events

Check out the News & Announcements to learn more.

Power Query PA Forum 768x460.png

Check it out!

Did you know that you can visit the Power Query Forum in Power BI and now Power Apps

Carousel 2021 Release Wave 2 Plan 768x460.jpg

2021 Release Wave 2 Plan

Power Platform release plan for the 2021 release wave 2 describes all new features releasing from October 2021 through March 2022.

PowerPlatform 768x460.png

Microsoft Learn

Check out our new Discover Your Career Path blog post series and get all the details.

Users online (3,032)