cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
FahadJaved212
Frequent Visitor

Power App Gallery sort issue

I am trying to sort my Gallery items from SharePoint list column with the below query but i am not getting desired sorting result. 

I have one column name : "Status" which has 3 options: "Active", "Cancelled" and "Renewal in Progress"

I want to sort results with "Renewal in Progress" show first in order , and "Active" in second order. See my code and advise where i am missing ? There is filter query inside Sort which filter specific criteria to show the items. 

 

Sort(
Filter(
[@'SADARA ID'],
And(
StartsWith(
isUsername.DisplayName,
TextSearchBox1.Text
)|| StartsWith(
Title,
TextSearchBox1.Text)
|| StartsWith(
SadaraBadgeID,
TextSearchBox1.Text
) || StartsWith(
UserName,
TextSearchBox1.Text
),
Status.Value = var_Activelist ||
Status.Value = var_WIPlist
)
), "Status" , SortOrder.Descending
)

 

2 ACCEPTED SOLUTIONS

Accepted Solutions
RandyHayes
Super User
Super User

@FahadJaved212 

Sorting will only sort by the alphabetic order.

Please consider changing your Formula to the following:

With({_data:
    Filter('SADARA ID',
        StartsWith(isUsername.DisplayName, TextSearchBox1.Text) || StartsWith(Title, TextSearchBox1.Text) || StartsWith(SadaraBadgeID, TextSearchBox1.Text) || StartsWith(UserName, TextSearchBox1.Text),
        Status.Value = var_Activelist || Status.Value = var_WIPlist
    )
    }, 
    
    Sort(
        AddColumns(_data, 
            "_statValue", Switch(Status.Value, "Active", 2, "Renewal in Progress", 1, "Cancelled", 3)
        ),
        _statValue, SortOrder.Ascending
    )
)    

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

View solution in original post

v-yujincui-msft
Community Support
Community Support

Hi @FahadJaved212 ,

 

Is your app created using the 'Start from SharePoint' method?

Maybe you could try to select the form control and apply the following formula on its Item property as:

LookUp([@'SADARA ID'],BrowseGallery1.Selected.ID=ID)

vyujincuimsft_0-1659941003461.png

 

 

Best Regards,

Charlie Choi

View solution in original post

7 REPLIES 7
WarrenBelz
Super User
Super User

Hi @FahadJaved212 ,

EDIT - go with @RandyHayes here

RandyHayes
Super User
Super User

@FahadJaved212 

Sorting will only sort by the alphabetic order.

Please consider changing your Formula to the following:

With({_data:
    Filter('SADARA ID',
        StartsWith(isUsername.DisplayName, TextSearchBox1.Text) || StartsWith(Title, TextSearchBox1.Text) || StartsWith(SadaraBadgeID, TextSearchBox1.Text) || StartsWith(UserName, TextSearchBox1.Text),
        Status.Value = var_Activelist || Status.Value = var_WIPlist
    )
    }, 
    
    Sort(
        AddColumns(_data, 
            "_statValue", Switch(Status.Value, "Active", 2, "Renewal in Progress", 1, "Cancelled", 3)
        ),
        _statValue, SortOrder.Ascending
    )
)    

 

I hope this is helpful for you.

_____________________________________________________________________________________
Digging it? - Click on the Thumbs Up below. Solved your problem? - Click on Accept as Solution below. Others seeking the same answers will be happy you did.
NOTE: My normal response times will be Mon to Fri from 1 PM to 10 PM UTC (and lots of other times too!)
Check out my PowerApps Videos too! And, follow me on Twitter @RandyHayes

Really want to show your appreciation? Buy Me A Cup Of Coffee!

Hi 

Randy, Thanks the code works for me. But with this formula  i encounter issue with "item" Details screen and edit screen. The error says , "Invalid formula , expect a value compatible with Datasource"  .

So i am not able to see detail information for the gallery item. 

Hi 

 Solution works for me, But with this formula  i encounter issue with "item" Details screen and edit screen. The error says , "Invalid formula , expect a value compatible with Datasource"  .

So i am not able to see detail information for the selected gallery item. It is empty.

FahadJaved212
Frequent Visitor

Hello Randy, Can you advise  with issue ?

v-yujincui-msft
Community Support
Community Support

Hi @FahadJaved212 ,

 

Is your app created using the 'Start from SharePoint' method?

Maybe you could try to select the form control and apply the following formula on its Item property as:

LookUp([@'SADARA ID'],BrowseGallery1.Selected.ID=ID)

vyujincuimsft_0-1659941003461.png

 

 

Best Regards,

Charlie Choi

FahadJaved212
Frequent Visitor

Many thanks for the help. It works. 

Helpful resources

Announcements
Ignite 2022

WHAT’S NEXT AT MICROSOFT IGNITE 2022

Explore the latest innovations, learn from product experts and partners, level up your skillset, and create connections from around the world.

Power Apps Africa Challenge 2022

Power Apps Africa Challenge

Your chance to join an engaging competition of Power Platform enthusiasts.

Users online (1,181)