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 / Bad sorting + warning ...
Power Apps
Unanswered

Bad sorting + warning error

(0) ShareShare
ReportReport
Posted on by 72

I have a gallery that filters my columns based in certain criteria.

The bad sorting ocurrs while i try to filter two of my columns( these two are of type single line of text), i don't know why the sort order works like this.

DidacRoig_0-1682328537768.png

Supplier is sorted descending, and 4017 is the first item while it has to be the last.

Why it works like this? Is there a form to make power apps order like excel, from A-Z and Z-A?

 

And the second error is that when i sort my date columns:

DidacRoig_0-1682328875672.png

It sorts properly, but every time that i click on Expiry date a pop up error ocurrs:

DidacRoig_1-1682330197578.png

Why is it giving me an error if it is working?Is there any form to make it not pop up? 

 

Categories:
  • BCBuizer Profile Picture
    22,854 Super User 2026 Season 2 on at

    Hi @DidacRoig ,

     

    As for the first topic, try wrapping the column name in the Value function.

     

    For the second issue, please share the formula that is causing the issue.

  • victorcp Profile Picture
    2,350 Moderator on at

    Hi,

    Suplier: problably the column is Text and not Number that's why it is the first in Descending order.

    ExpiryDate: in this case you have to use the column internal name and I think it is wrong, can you check it please?

     

    please let me know if you have any doubts

  • DidacRoig Profile Picture
    72 on at

    Why if the column is in text format it filters the first? is not a form that it sorts like Excel?

    As form the second question, this is my code:

    In the sort button -->  If(Toggle1.Value,Set(varSortColumn,"Required_x0020_Date"),Set(varSortColumn,"Expirydate"));Set(varSortDirection,If(varSortDirection=SortOrder.Ascending,SortOrder.Descending,SortOrder.Ascending))

     

    In the gallery-->

    SortByColumns(
    Filter(
    DerogationTest,
    IsBlank(fSupplier) || StartsWith(
    Supplier,
    fSupplier.Text
    ),
    IsBlank(fDate) || StartsWith(
    DateYear,
    fDate.Text
    ),
    IsBlank(fResult) || Status.Value = fResult.Selected.Value,
    IsBlank(Trim(Filter)) || StartsWith(
    AID,
    Filter.Text
    ),
    IsBlank(Trim(fMaterial)) || StartsWith(
    Material,
    fMaterial.Text
    ),
    IsBlank(varPlant) || Plant.Value = varPlant
    ),
    varSortColumn,
    If(
    varSortDirection = SortOrder.Ascending,
    SortOrder.Ascending,
    SortOrder.Descending
    )
    )

     

    DateYear is a column in my sharepoint list that saves a year.

  • BCBuizer Profile Picture
    22,854 Super User 2026 Season 2 on at

    Hi @DidacRoig ,

     

    Can you try the below to resolve the first issue:

    SortByColumns(
    	Filter(
    		DerogationTest,
    		IsBlank(fSupplier) || StartsWith(
    			Supplier,
    			fSupplier.Text
    		),
    		IsBlank(fDate) || StartsWith(
    			DateYear,
    			fDate.Text
    		),
    		IsBlank(fResult) || Status.Value = fResult.Selected.Value,
    		IsBlank(Trim(Filter)) || StartsWith(
    			AID,
    			Filter.Text
    		),
    		IsBlank(Trim(fMaterial)) || StartsWith(
    			Material,
    			fMaterial.Text
    		),
    		IsBlank(varPlant) || Plant.Value = varPlant
    	),
    	If(
    		varSortColumn = "Supplier",
    		Value(varSortColumn),
    		varSortColumn
    	),
    	If(
    		varSortDirection = SortOrder.Ascending,
    		SortOrder.Ascending,
    		SortOrder.Descending
    	)
    )

    I added a condition to apply the Value function in case the "Supplier" column is selected in varSortColumn.

     

    As for the second issue I'd need to know how varSortColumn is set. I have a suspicion that maybe there's just a speeling mistake where you wrote "Expirydate" where it should be "ExpiryDate" (with a capital D). 

     

    To be sure, check the internal name of the column in SharePoint.

  • DidacRoig Profile Picture
    72 on at

    As for the first question, it gives me an error that the formula expects a text value and im giving it a number.

    As for the second, my field value in nsharepoint is Field=Expirydate.

    An my set for the button is set like this:

    If(
    Toggle1.Value,
    Set(
    varSortColumn,
    "Required_x0020_Date"
    ),
    Set(
    varSortColumn,
    "Expirydate"
    )
    );
    Set(
    varSortDirection,
    If(
    varSortDirection = SortOrder.Ascending,
    SortOrder.Descending,
    SortOrder.Ascending
    )
    )

     

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 381 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 340

#3
WarrenBelz Profile Picture

WarrenBelz 187 Most Valuable Professional

Last 30 days Overall leaderboard