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 Apps
Unanswered

Gallery Display

(0) ShareShare
ReportReport
Posted on by 1,265

I have the following for the 'Items' properties of a gallery.  When the app is originally opened no records are displayed.  If one of the sort options is selected, then records appear.  How do I default to all records when the App opens?

 

Switch(varSortColumn,"BldgAptRm",SortByColumns(Filter([@RZMaintInspection],StartsWith(AptNo,TextSearchBox1.Text) && (CreatedbyDN = Dropdown3_1.Selected.Value || Dropdown3_1.Selected.Value = Blank()) && (ZoneLU = Radio2.Selected.Value || Radio2.Selected.Value = Blank()) && (Building = Dropdown3.Selected.Bldg || Dropdown3.Selected.Bldg = Blank())),
"BldgAptRm",If(varSortColumn = SortOrder.Ascending,SortOrder.Ascending,SortOrder.Descending)),
"Created",SortByColumns(Filter([@RZMaintInspection],StartsWith(AptNo,TextSearchBox1.Text) && (CreatedbyDN = Dropdown3_1.Selected.Value || Dropdown3_1.Selected.Value = Blank()) && (ZoneLU = Radio2.Selected.Value || Radio2.Selected.Value = Blank()) && (Building = Dropdown3.Selected.Bldg || Dropdown3.Selected.Bldg = Blank())),"Created",If(varSortColumn = SortOrder.Ascending,SortOrder.Ascending,SortOrder.Descending)),
"Points",SortByColumns(Filter([@RZMaintInspection],StartsWith(AptNo,TextSearchBox1.Text) && (CreatedbyDN = Dropdown3_1.Selected.Value || Dropdown3_1.Selected.Value = Blank()) && (ZoneLU = Radio2.Selected.Value || Radio2.Selected.Value = Blank()) && (Building = Dropdown3.Selected.Bldg || Dropdown3.Selected.Bldg = Blank())),"Points",If(varSortColumn = SortOrder.Ascending,SortOrder.Ascending,SortOrder.Descending))

 

RJF61_0-1686667785481.png

 

Categories:
I have the same question (0)
  • LaurensM Profile Picture
    12,516 Moderator on at

    Hi @RJF61,

     

    You currently do not have a Default case within the switch, only ones for bldgAptRm, Created & Points. When opening the app, varSortColumn will most likely not have a value - meaning the Switch returns nothing because it does not have a case value that matches.

     

    I am a bit confused about the use of varSortColumn both for a text value (see first Switch parameter) and as a SortOrder value. Could it be that these should refer to 2 different variables?

     

    We could rewrite the code slightly to avoid some code duplication and increase readability. For the example below I used varSortColumn for both cases as well and the default switch will sort via the ID:

    SortByColumns(
     Filter(
     [@RZMaintInspection],
     StartsWith(AptNo,TextSearchBox1.Text), 
     (CreatedbyDN = Dropdown3_1.Selected.Value || Dropdown3_1.Selected.Value = Blank()), 
     (ZoneLU = Radio2.Selected.Value || Radio2.Selected.Value = Blank()), 
     (Building = Dropdown3.Selected.Bldg || Dropdown3.Selected.Bldg = Blank())
     ),
     Switch(
     varSortColumn, 
     "BldgAptRm",
     "BldgAptRm",
     "Created",
     "Created",
     "Points",
     "Points",
     //By default use Id (you might have to rewrite "Id" to the exact, correct column name
     "Id"
     ),
     //Make sure the variable below is filled during the OnStart with e.g. SortOrder.Ascending otherwise this will throw an error
     If(varSortColumn = SortOrder.Ascending,SortOrder.Ascending,SortOrder.Descending)
    )

     

    If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.

    Thanks!

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

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 305 Most Valuable Professional

#2
11manish Profile Picture

11manish 212

#3
Valantis Profile Picture

Valantis 167

Last 30 days Overall leaderboard