web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Sort filter Gallery pe...
Power Apps
Answered

Sort filter Gallery per status

(0) ShareShare
ReportReport
Posted on by 89

Hi,
I've built a new gallery with items details and status.
Those Items can have 4 different status, NewIn Progress, Cancel and Close.
I've created 4 buttons for the 4 status.
Each buttons as OnSelect field

 

UpdateContext({FilterByNew:!FilterByNew})

UpdateContext({FilterByInProgress:!FilterByInProgress})

UpdateContext({FilterByCancel:!FilterByCancel})

UpdateContext({FilterByClose:!FilterByClose})

 

 

Now, my goal is to sort/filter my gallery per statu when i click on one of the buttons, and this is where I'm having problem.
It does not filter correctly. I need to click twice for something to filter correctly,

Here is the code that i have put on the Gallery Items:

 

 

If(
 FilterByClosed = true,
 (Sort(
 Filter(
 '[QA_Data].[AUDIT_REQUEST]',
 (REQUESTER_USER_NAME = (lbUserName_R004.Text) && STATUS_OF_REQUEST = "Close")
 ),
 SYSTEM_SUBMITTED_DATE_TIME,
 Ascending
 )),
 If(
 FilterByNew = true,
 (Sort(
 Filter(
 '[QA_Data].[AUDIT_REQUEST]',
 (REQUESTER_USER_NAME = (lbUserName_R004.Text) && STATUS_OF_REQUEST = "New")
 ),
 SYSTEM_SUBMITTED_DATE_TIME,
 Ascending
 )),
 If(
 FilterByCancel = true,
 (Sort(
 Filter(
 '[QA_Data].[AUDIT_REQUEST]',
 (REQUESTER_USER_NAME = (lbUserName_R004.Text) && STATUS_OF_REQUEST = "Cancel")
 ),
 SYSTEM_SUBMITTED_DATE_TIME,
 Ascending
 )),
 If(
 FilterByInProgress = true,
 (Sort(
 Filter(
 '[QA_Data].[AUDIT_REQUEST]',
 (REQUESTER_USER_NAME = (lbUserName_R004.Text) && STATUS_OF_REQUEST = "In Progress")
 ),
 SYSTEM_SUBMITTED_DATE_TIME,
 Ascending
 )), Sort(
 Filter(
 '[QA_Data].[AUDIT_REQUEST]',
 (REQUESTER_USER_NAME = (lbUserName_R004.Text) && STATUS_OF_REQUEST < > "")
 ),
 SYSTEM_SUBMITTED_DATE_TIME,
 Descending
 )
 )
 )
 )
)

 

 

Can you please help me with this issue?

Thanks again for all the help.

 

Categories:
  • Verified answer
    WarrenBelz Profile Picture
    156,576 Most Valuable Professional on at

    Hi @Wilder1626 ,

    Firstly, you can get your filter a bit optimized as below

    Sort(
     Filter(
     '[QA_Data].[AUDIT_REQUEST]',
     REQUESTER_USER_NAME = lbUserName_R004.Text && STATUS_OF_REQUEST < > "" &&
     (!FilterByClosed || STATUS_OF_REQUEST = "Close") && 
     (!FilterByNew || STATUS_OF_REQUEST = "New") &&
     (!FilterByCancel || STATUS_OF_REQUEST = "Cancel") &&
     (!FilterByInProgress || STATUS_OF_REQUEST = "In Progress")
     ),
     SYSTEM_SUBMITTED_DATE_TIME,
     Descending
    )

    however the real issue is that you are not resetting the "other" filters

    UpdateContext({FilterByNew:!FilterByNew});
    If(
     FilterByNew,
     UpdateContext(
     { 
     FilterByInProgress:false,
     FilterByCancel:false,
     FilterByClose:false
     }
    )

    and the same for the rest.

     

    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.

  • Wilder1626 Profile Picture
    89 on at

    Thanks, i will give this a try and will get back to you.

  • Wilder1626 Profile Picture
    89 on at

    Thanks a lot for your help. Now it's working great.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 382 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 329

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard