cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
almecum
Level: Power Up

Help with filter with "and" and "or"

Hi

I need help on how to correct this code. The below filter works for the second clause if the checkbox is not closed. I need the same for the first part when the checkbox is checked. 

 

Maybe this is not the correct way to do it. 

Ask: I need to show only data where the status <> closed and when the checkbox is checked then only for a spacific user. I was doing it using a filter but maybe there is a simpler way of doing it.

Thanks

 

If(Checkbox1.Value = true,SortByColumns(Filter('X-Dependency Tracker 1.0 v1', StartsWith('Dependency Owner'.DisplayName, CurrentUser.FullName)|| StartsWith(Requestor.DisplayName, CurrentUser.FullName)), "Title", If(SortDescending1, Descending, Ascending)),SortByColumns(Filter('X-Dependency Tracker 1.0 v1', StartsWith('Dependency Owner'.DisplayName, FilterTextBox.Text) && 'State'.Value <> "Closed"), "Title", If(SortDescending1, Descending, Ascending)))
1 ACCEPTED SOLUTION

Accepted Solutions
Super User
Super User

Re: Help with filter with "and" and "or"

Hi @almecum 

 

Try

 

If(Checkbox1.Value,SortByColumns(Filter('X-Dependency Tracker 1.0 v1', (StartsWith('Dependency Owner'.DisplayName, CurrentUser.FullName)|| StartsWith(Requestor.DisplayName, CurrentUser.FullName)) && 'State'.Value <> "Closed"), "Title", If(SortDescending1, Descending, Ascending)),SortByColumns(Filter('X-Dependency Tracker 1.0 v1', StartsWith('Dependency Owner'.DisplayName, FilterTextBox.Text) && 'State'.Value <> "Closed"), "Title", If(SortDescending1, Descending, Ascending)))

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

3 REPLIES 3
Super User
Super User

Re: Help with filter with "and" and "or"

Hi @almecum 

 

Try

 

If(Checkbox1.Value,SortByColumns(Filter('X-Dependency Tracker 1.0 v1', (StartsWith('Dependency Owner'.DisplayName, CurrentUser.FullName)|| StartsWith(Requestor.DisplayName, CurrentUser.FullName)) && 'State'.Value <> "Closed"), "Title", If(SortDescending1, Descending, Ascending)),SortByColumns(Filter('X-Dependency Tracker 1.0 v1', StartsWith('Dependency Owner'.DisplayName, FilterTextBox.Text) && 'State'.Value <> "Closed"), "Title", If(SortDescending1, Descending, Ascending)))

 

Regards,

Reza Dorrani

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

View solution in original post

Super User
Super User

Re: Help with filter with "and" and "or"

Have you tested to make sure 'Dependency Owner'.DisplayName has the exact name as CurrentUser.FullName? I ask because User().FullName and SPOPersonField.Name doesn't return the exact same name for me in my tenant. 

 

If that ends up being the issue you could try using the email address.

StartsWith('Dependency Owner'.Email, CurrentUser.Email)

StartsWith(Requestor.Email = CurrentUser.Email)

 



--------------------------------------------------------------------------------
If this post helps answer your question, please click on “Accept as Solution” to help other members find it more quickly. If you thought this post was helpful, please give it a Thumbs Up.
almecum
Level: Power Up

Re: Help with filter with "and" and "or"

Hi

I did set a variable on app start to set CurrentUser from User() so it is working for me. I used text boxes to check the value they both returned, and so far its all working. I am also using People fields in SharePoint for DependencyOwner and Requestor.

Helpful resources

Announcements
firstImage

Microsoft Business Applications Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

Top Kudoed Authors
Users Online
Currently online: 250 members 3,350 guests
Please welcome our newest community members: