Skip to main content

Notifications

Community site session details

Community site session details

Session Id : q1gtCJR5giJ3SxM/6rFIs/
Power Apps - Building Power Apps
Unanswered

sort function not working

Like (0) ShareShare
ReportReport
Posted on 1 Jun 2020 15:50:34 by

this is my gallery items

 

 

Sort(
 Filter(
 'Main Form Information',
 FormTypeDrop.Selected.Result in Concat('Form Type',Value,","),
 AuditTypeDrop.Selected.Result in Concat('Audit Type',Value,","),
 AuditorDrop.Selected.Result in Auditor.DisplayName,
 RegionDrop.Selected.Result in Region.Value,
 DateCheck <= 'Inspection Date',
 Switch(SearchNonCon.Selected.Value,
 "All", 
 true ,
 "Yes",
 If(CountRows(Filter(RenameColumns('New Non-Conformance',"ID","Non-ConId"),'Foreign Key'= ID))
 >
 0, 
 true,
 false
 ),
 "No",
 If(
 Not(
 CountRows(
 Filter(RenameColumns('New Non-Conformance',"ID","Non-ConId"),'Foreign Key'= ID)
 )
 >
 0
 ),
 true,
 false 
 )
 )
 ),
 sortColumn,
 AorD
)

 

 

i have some buttons that change the value of "sortColumn" to a text input of the applicable column that you want to sort by. the variable changes, I can see that. but it doesn't actually change how the list shows up in the gallery. 

AorD is the same idea but it changes from ascending or descending when a button is pressed.

  • v-bofeng-msft Profile Picture
    on 03 Jun 2020 at 01:46:16
    Re: sort function not working

    Hi @Anonymous :

    I suggest you save the result of this code to a collection and then check if the "Inspection Date" field exists.

    For example:

     

    ClearCollect(Thecollection,
     Filter(
     'Main Form Information',
     FormTypeDrop.Selected.Result in Concat('Form Type',Value,","),
     AuditTypeDrop.Selected.Result in Concat('Audit Type',Value,","),
     AuditorDrop.Selected.Result in Auditor.DisplayName,
     RegionDrop.Selected.Result in Region.Value,
     DateCheck <= 'Inspection Date',
     Switch(SearchNonCon.Selected.Value,
     "All", 
     true ,
     "Yes",
     If(CountRows(Filter(RenameColumns('New Non-Conformance',"ID","Non-ConId"),'Foreign Key'= ID))
     >
     0, 
     true,
     false
     ),
     "No",
     If(
     Not(
     CountRows(
     Filter(RenameColumns('New Non-Conformance',"ID","Non-ConId"),'Foreign Key'= ID)
     )
     >
     0
     ),
     true,
     false 
     )
     )
     ))

     

    Best Regards,

    Bof

     

  • Community Power Platform Member Profile Picture
    on 02 Jun 2020 at 13:51:17
    Re: sort function not working

    I've used this code for a good bit with no issue then i went to add the filter and for whatever reason it won't identify a column I even tried hard coding the column name and thats not even working.

     

    SortByColumns(
     Filter(
     'Main Form Information',
     FormTypeDrop.Selected.Result in Concat('Form Type',Value,","),
     AuditTypeDrop.Selected.Result in Concat('Audit Type',Value,","),
     AuditorDrop.Selected.Result in Auditor.DisplayName,
     RegionDrop.Selected.Result in Region.Value,
     DateCheck <= 'Inspection Date',
     Switch(SearchNonCon.Selected.Value,
     "All", 
     true ,
     "Yes",
     If(CountRows(Filter(RenameColumns('New Non-Conformance',"ID","Non-ConId"),'Foreign Key'= ID))
     >
     0, 
     true,
     false
     ),
     "No",
     If(
     Not(
     CountRows(
     Filter(RenameColumns('New Non-Conformance',"ID","Non-ConId"),'Foreign Key'= ID)
     )
     >
     0
     ),
     true,
     false 
     )
     )
     ),
     "Inspection Date"
    )
  • v-bofeng-msft Profile Picture
    on 02 Jun 2020 at 01:59:46
    Re: sort function not working

    Hi @Anonymous :

    Thanks for @mdevaney 's solution, I made a test but did not encounted any problem.

    My code:

     

    SortByColumns(MyPhoto,sortColumn,AorD) /*MyPhoto is my data source*/

     

     

    3.gif

    Could you check if the result of this code is empty?

     

     Filter(
     'Main Form Information',
     FormTypeDrop.Selected.Result in Concat('Form Type',Value,","),
     AuditTypeDrop.Selected.Result in Concat('Audit Type',Value,","),
     AuditorDrop.Selected.Result in Auditor.DisplayName,
     RegionDrop.Selected.Result in Region.Value,
     DateCheck <= 'Inspection Date',
     Switch(SearchNonCon.Selected.Value,
     "All", 
     true ,
     "Yes",
     If(CountRows(Filter(RenameColumns('New Non-Conformance',"ID","Non-ConId"),'Foreign Key'= ID))
     >
     0, 
     true,
     false
     ),
     "No",
     If(
     Not(
     CountRows(
     Filter(RenameColumns('New Non-Conformance',"ID","Non-ConId"),'Foreign Key'= ID)
     )
     >
     0
     ),
     true,
     false 
     )
     )
     )

     

     Best Regards,

    Bof

  • Community Power Platform Member Profile Picture
    on 01 Jun 2020 at 16:30:45
    Re: sort function not working

    it shows the gallery completely empty when i do that.

  • Community Power Platform Member Profile Picture
    on 01 Jun 2020 at 16:29:50
    Re: sort function not working

    I thought that as well and it's not working with that either

  • mdevaney Profile Picture
    29,987 Super User 2025 Season 1 on 01 Jun 2020 at 16:16:19
    Re: sort function not working

    @Anonymous 
    The issue is you are trying to supply a screen name to the SORT function.  This cannot be done.  Instead, you must use the SORTCOLUMNS function.

     

    SortColumns(
        your_filter_code_here,
        sortColumn,
        AorD
    )

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up." 

  • Community Power Platform Member Profile Picture
    on 01 Jun 2020 at 16:06:56
    Re: sort function not working

    this is in the app onStart

     

    Set(AorD,Descending);
    Set(sortColumn,"Inspection Date")

     



    this is in the buttons' onSelect field

     

    //button one
    Set(sortColumn,"Inspection Date")
    //button two
    Set(sortColumn,"Auditor")

    and this is in the inverting order icon

    Set(AorD,If(AorD = Descending,Ascending,Descending));

     

     

  • mdevaney Profile Picture
    29,987 Super User 2025 Season 1 on 01 Jun 2020 at 15:53:54
    Re: sort function not working

    @Anonymous 
    It would be a good idea to share the code you are using to SET SortColumn and AorD.  The code you supplied is fine, but it doesn't tell the whole story.

     

    ---
    Please click "Accept as Solution" if my post answered your question so that others may find it more quickly. If you found this post helpful consider giving it a "Thumbs Up." 

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

Understanding Microsoft Agents - Introductory Session

Confused about how agents work across the Microsoft ecosystem? Register today!

Warren Belz – Community Spotlight

We are honored to recognize Warren Belz as our May 2025 Community…

Congratulations to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Power Apps - Building Power Apps

#1
MS.Ragavendar Profile Picture

MS.Ragavendar 32

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 19 Super User 2025 Season 1

#3
Rajkumar_M Profile Picture

Rajkumar_M 16 Super User 2025 Season 1

Overall leaderboard