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

SearchBox combining with sort function

Hello everyone,

Please help figure it out.

Have gallery and sort(Filetr functions. 

Wanted to insert search box to find tickets by using ID and Owner.

Got so many examples but realise that dont know how to combine them with each other without losing a data.

Can anyone help me with that. Code is below. Item property of my gallery.

 

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
               )
            )
         )
      )
   ),
   DateCreated,
   Descending
)

 

OnStart property of my app is:

 

Set(
    CurrentUserUPN,
    Office365Users.MyProfile().UserPrincipalName
);
ClearCollect(
    O365GroupMembers,
    Office365Groups.ListGroupMembers("OURGROUPID").value
);
Set(
    IsO365GroupMember,
    If(
        !IsBlank(
            LookUp(
                O365GroupMembers,
                userPrincipalName = CurrentUserUPN
            )
        ),
        true,
        false
    )
);
Set(
    varUserPrincipalName,
    Lower(User().FullName)
);

 

Please ignore last row of code, trying to restrict access for users)

Thank you in advance.

1 ACCEPTED SOLUTION

Accepted Solutions

Hi @ArmanGabd :

Could you tell me:

What are ID and Owner's date type?Are they all text type?

I assume they are all text columns ,please try this formula:

If(
    IsBlank(TextInput1.Text),
    Tickets,
    Search(
        Tickets,
        TextInput1.Text,
        "ID",
        "Owner"
    )
)

The Gallery's items property should be:

With(
   {Galleryitem: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
               )
            )
         )
      )
   ),
   DateCreated,
   Descending
)},If(
    IsBlank(TextInput1.Text),
    Galleryitem,
    Search(
        Galleryitem,
        TextInput1.Text,
        "ID",
        "Owner"
    )
))

Or the code could be:

If(
    IsBlank(TextInput1.Text),
    Tickets,
    Filter(
        Tickets,
        TextInput1.Text in ID || TextInput1.Text in Owner
    )
)

 The Gallery's items property should be:

With(
   {Galleryitem: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
               )
            )
         )
      )
   ),
   DateCreated,
   Descending
)},If(
    IsBlank(TextInput1.Text),
    Tickets,
    Filter(
        Galleryitem,
        TextInput1.Text in ID || TextInput1.Text in Owner
    )
))

Best Regards,

Bof

View solution in original post

3 REPLIES 3
ArmanGabd
Helper I
Helper I

I have this code for search function:

If(
    IsBlank(TextInput1.Text),
    Tickets,
    Filter(
        Tickets,
        TextInput1.Text in ID and Owner
    )
)

Trying to combine and add it to my items property in correct way without losing data.

Hi @ArmanGabd :

Could you tell me:

What are ID and Owner's date type?Are they all text type?

I assume they are all text columns ,please try this formula:

If(
    IsBlank(TextInput1.Text),
    Tickets,
    Search(
        Tickets,
        TextInput1.Text,
        "ID",
        "Owner"
    )
)

The Gallery's items property should be:

With(
   {Galleryitem: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
               )
            )
         )
      )
   ),
   DateCreated,
   Descending
)},If(
    IsBlank(TextInput1.Text),
    Galleryitem,
    Search(
        Galleryitem,
        TextInput1.Text,
        "ID",
        "Owner"
    )
))

Or the code could be:

If(
    IsBlank(TextInput1.Text),
    Tickets,
    Filter(
        Tickets,
        TextInput1.Text in ID || TextInput1.Text in Owner
    )
)

 The Gallery's items property should be:

With(
   {Galleryitem: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
               )
            )
         )
      )
   ),
   DateCreated,
   Descending
)},If(
    IsBlank(TextInput1.Text),
    Tickets,
    Filter(
        Galleryitem,
        TextInput1.Text in ID || TextInput1.Text in Owner
    )
))

Best Regards,

Bof

View solution in original post

Thank you very much man, need to learn how to combine different functions in one property)

Solution is:

With(
   {Galleryitem: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
               )
            )
         )
      )
   ),
   DateCreated,
   Descending
)},If(
    IsBlank(TextInput1.Text),
    Galleryitem,
    Search(
        Galleryitem,
        TextInput1.Text,
        "ID",
        "Owner"
    )
))

Tryed second option, but filtering function didnt work properly.

Thanks,

 

P.S. This is for future users who will search similar issue)

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,778)