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 / Struggelig to combine ...
Power Apps
Answered

Struggelig to combine sort and filter formulas in a gallery

(0) ShareShare
ReportReport
Posted on by 14

I have a gallery that is connected to a sharepoint list. 

 As of now, I have a filter formula that works, but when i try to add a sort function, I just get a lot of errors. 

 

The filter formula alone: 

Filter(
[@EfaNSO];
(StartsWith(
'Innsendt av'.DisplayName;
searchbox.Text
) || StartsWith(
'ID nummer';
searchbox.Text
) || StartsWith(
'Informasjon om saken';
searchbox.Text
) || StartsWith(
Sakstype.Value;
searchbox.Text
) || StartsWith(
Kategori.Value;
searchbox.Text
) || StartsWith(
Underkategori.Value;
searchbox.Text
) || StartsWith(
'Innmeldt dato';
searchbox.Text
)) && (Kategori.Value = Drop_kat_1.Selected.Value || Drop_kat_1.Selected.Value = Blank()) && (Status.Value = Drop_kat_5.Selected.Value || Drop_kat_5.Selected.Value = Blank()) && (Underkategori.Value = Drop_kat_2.Selected.Value || Drop_kat_2.Selected.Value = Blank()) && (Sakstype.Value = Drop_kat_4.Selected.Value || Drop_kat_4.Selected.Value = Blank()) && ('Innsendt av'.DisplayName = DataCardValue36_1.Selected.DisplayName || DataCardValue36_1.Selected.DisplayName = Blank())
)

 

When i try to add the sort formula, i set it up like this: 

 

Sort(Filter(
[@EfaNSO];
(StartsWith(
'Innsendt av'.DisplayName;
searchbox.Text
) || StartsWith(
'ID nummer';
searchbox.Text
) || StartsWith(
'Informasjon om saken';
searchbox.Text
) || StartsWith(
Sakstype.Value;
searchbox.Text
) || StartsWith(
Kategori.Value;
searchbox.Text
) || StartsWith(
Underkategori.Value;
searchbox.Text
) || StartsWith(
'Innmeldt dato';
searchbox.Text
)) && (Kategori.Value = Drop_kat_1.Selected.Value || Drop_kat_1.Selected.Value = Blank()) && (Status.Value = Drop_kat_5.Selected.Value || Drop_kat_5.Selected.Value = Blank()) && (Underkategori.Value = Drop_kat_2.Selected.Value || Drop_kat_2.Selected.Value = Blank()) && (Sakstype.Value = Drop_kat_4.Selected.Value || Drop_kat_4.Selected.Value = Blank()) && ('Innsendt av'.DisplayName = DataCardValue36_1.Selected.DisplayName || DataCardValue36_1.Selected.DisplayName = Blank()); EfaNSO; 'Innmeldt dato'; SortOrder.Descending)
)


Clearly I'm doing something wrong, but I struggle to spot the problem. When I'm adding the sort function, I can see somethinh happening in the gallery, but the data won't show. Could anyone take a look at it?

 

sort_filter.png
Categories:
  • BCBuizer Profile Picture
    22,899 Super User 2026 Season 2 on at

    Hi @cls85,

     

    I see you are trying to pass two columns to sort by (EfaNSO; 'Innmeldt dato';), but the Sort function will only take 1: https://learn.microsoft.com/en-us/power-platform/power-fx/reference/function-sort#syntax

     

    Also you have the closing bracket for the Filter function in the wrong place.

     

    In case you want to sort by multiple columns, use the SortByColumns function. Please bear in mind these take literal values for the internal names of the columns. In case the internal names are the same as the DisplayNames, the below should work:

     

     

    SortByColumns(
    	Filter(
    		[@EfaNSO];
    		StartsWith('Innsendt av'.DisplayName; searchbox.Text) || 
    		StartsWith('ID nummer';	searchbox.Text) || 
    		StartsWith('Informasjon om saken'; searchbox.Text) || 
    		StartsWith(Sakstype.Value; searchbox.Text) || 
    		StartsWith(Kategori.Value; searchbox.Text) || 
    		StartsWith(Underkategori.Value;	searchbox.Text) || 
    		StartsWith('Innmeldt dato'; searchbox.Text);
    		
    		Kategori.Value = Drop_kat_1.Selected.Value || Drop_kat_1.Selected.Value = Blank();
    		Status.Value = Drop_kat_5.Selected.Value || Drop_kat_5.Selected.Value = Blank();
    		Underkategori.Value = Drop_kat_2.Selected.Value || Drop_kat_2.Selected.Value = Blank();
    		Sakstype.Value = Drop_kat_4.Selected.Value || Drop_kat_4.Selected.Value = Blank();
    		'Innsendt av'.DisplayName = DataCardValue36_1.Selected.DisplayName || DataCardValue36_1.Selected.DisplayName = Blank()
    	);
    	"EfaNSO";
    	"Innmeldtdato"; 
    	SortOrder.Descending
    )

     

     

  • cls85 Profile Picture
    14 on at

    Well, something happened, but it won't show any of the data. I've tried to tweak a bit, but no luck. I don't get any warning towards the gallery items, but i get several warnings on the different title, subtitle and body boxes I have in the gallery list item.

     

    The errors that's showing is: "name is invalid" and "incorrect us of.." 

    warnings.png
  • cls85 Profile Picture
    14 on at

    Hi again,

     

    When a tweaked it a bit more, and i tried another formula:

     

    Filter( Sort(EfaNSO;'Innmeldt dato';SortOrder.Descending);
    [@EfaNSO];
    StartsWith(
    'Innsendt av'.DisplayName;
    searchbox.Text
    ) || StartsWith(
    'ID nummer';
    searchbox.Text
    ) || StartsWith(
    'Informasjon om saken';
    searchbox.Text
    ) || StartsWith(
    Sakstype.Value;
    searchbox.Text
    ) || StartsWith(
    Kategori.Value;
    searchbox.Text
    ) || StartsWith(
    Underkategori.Value;
    searchbox.Text
    ) || StartsWith(
    'Innmeldt dato';
    searchbox.Text
    );
    Kategori.Value = Drop_kat_1.Selected.Value || Drop_kat_1.Selected.Value = Blank();
    Status.Value = Drop_kat_5.Selected.Value || Drop_kat_5.Selected.Value = Blank();
    Underkategori.Value = Drop_kat_2.Selected.Value || Drop_kat_2.Selected.Value = Blank();
    Sakstype.Value = Drop_kat_4.Selected.Value || Drop_kat_4.Selected.Value = Blank();
    'Innsendt av'.DisplayName = DataCardValue36_1.Selected.DisplayName || DataCardValue36_1.Selected.DisplayName = Blank()
    )

     

    ... I get no errors, but the gallery is empty. But if I remove the sort formula, the filter formula works fine. 

  • Verified answer
    cls85 Profile Picture
    14 on at

    Fixed! 

     

    The formula that works is:

    Sort(Filter( [@EfaNSO];
    StartsWith('Innsendt av'.DisplayName; searchbox.Text) ||
    StartsWith('ID nummer'; searchbox.Text) ||
    StartsWith('Informasjon om saken'; searchbox.Text) ||
    StartsWith(Sakstype.Value; searchbox.Text) ||
    StartsWith(Kategori.Value; searchbox.Text) ||
    StartsWith(Underkategori.Value; searchbox.Text) ||
    StartsWith('Innmeldt dato'; searchbox.Text);
    Kategori.Value = Drop_kat_1.Selected.Value ||
    Drop_kat_1.Selected.Value = Blank(); Status.Value = Drop_kat_5.Selected.Value ||
    Drop_kat_5.Selected.Value = Blank(); Underkategori.Value = Drop_kat_2.Selected.Value ||
    Drop_kat_2.Selected.Value = Blank(); Sakstype.Value = Drop_kat_4.Selected.Value ||
    Drop_kat_4.Selected.Value = Blank(); 'Innsendt av'.DisplayName = DataCardValue36_1.Selected.DisplayName ||
    DataCardValue36_1.Selected.DisplayName = Blank() );'Innmeldt dato'; SortOrder.Descending)

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

    Hi @cls85 ,

     

    Good to see you got this working. I found I made a typo in my first response which I now corrected. In case you still wish to sort by two columns, you can try that option.

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

#2
M Bilal Khan Profile Picture

M Bilal Khan 271

#3
Mohsin Ali Profile Picture

Mohsin Ali 223

Last 30 days Overall leaderboard