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

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group

secondImage

Demo Extravaganza is Back!

We are excited to announce that Demo Extravaganza for 2021 has started!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

Power Apps June 2021

June Power Apps Community Call

Did you miss the call? Check out the recording here!

Top Solution Authors
Top Kudoed Authors
Users online (12,297)