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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Sort By Column and fil...
Power Apps
Unanswered

Sort By Column and filtering not working within a Power App that is an Data Table.

(1) ShareShare
ReportReport
Posted on by 4
I have been using a Data Table to filter results and now have a requirement to add a Column sort and sounds easy yeah, but cannot get it to work with the filter. The datasource is a SharePoint list and the below is being added to the Items field of the datatable within my Power App. The Filter works fine by itself but when i add a SortByColumn condition it does not display my filter or the new sort by column when i add any of the below conditions. I have tried the below with no success and maybe it is something simple i am missing, please assist? 

Example 1: 
SortByColumns(
Filter(
'DataSource',
'Field1'.Value = "No"
),
"Risk",
If(
Risk.Value = "High", 1,
Risk.Value = "Medium", 2,
Risk.Value = "Low", 3,
4 // Default value for any other cases
)

)
Error: 


Example 2: 

SortByColumns(
Filter('Datasource', 'Field1'.Value = "No"),
"Risk",
Ascending
)

Error: 
Cannot sort on the expression Type "Risk"

I suspect that the Risk Field is my issue but it is not different to the Filter field so not sure on why it does not. 

Thanks in advance for your assistance.

Mattyw2000
 
Categories:
I have the same question (0)
  • WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at
    You have not added the AddColumns function
    SortByColumns(
       AddColumns(
          Filter(
             'DataSource',
             'Field1'.Value = "No"
          ),
          RiskVal,
          Switch(
             Risk.Value,
             "High", 
             1,
             "Medium", 
             2,
             "Low", 
             3,
             4
          )
       ),
       "RiskVal",
       SortOrder.Ascending
    )
     
    Please click Does this answer your question 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 a Like.
    MVP (Business Applications)     Visit my blog Practical Power Apps    Buy me a coffee
  • Wee Teck Profile Picture
    45 on at
    SortByColumns(
       AddColumns(
          Filter(
             'DataSource',
             'Field1' = "No"  // Assuming Field1 is a text field
          ),
          "RiskVal",
          Switch(
             Risk,
             "High", 
             1,
             "Medium", 
             2,
             "Low", 
             3,
             4
          )
       ),
       "RiskVal",
       SortOrder.Ascending
    )


    We can simplify it (if these are text fields) by dropping .Value:
  • CU25092244-0 Profile Picture
    4 on at
    Hi Wee Teck and WarrenBelz, 
     
    Thanks for the responses and sorry about the delay in getting back to you. I have tried both those methods and it does not like my field Risk as it is a SharePoint List selection field as would that make any difference? 
     
    The errors i get now are: 
    "RiskVal" - Expected Identifier name
     
    "RiskVal" Does not exist
    My Filter alone will display data in my table correctly. 
     
    The errors are the same for both responses provided.
     
    Happy to provide further information,
     
    With Thanks,
     
    Mattyw2000
  • WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at
    You do not need quotes "" around "RiskVal" in the fourth line.
  • WarrenBelz Profile Picture
    153,034 Most Valuable Professional on at
    Just following up to see if you received the answer you needed, or if you require further assistance.

    Please click Does this answer your question 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 a Like.
    MVP (Business Applications)     Visit my blog Practical Power Apps    Buy me a coffee

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

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 717 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 329 Super User 2025 Season 2

#3
Power Platform 1919 Profile Picture

Power Platform 1919 268

Last 30 days Overall leaderboard