Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Unanswered

Adding a sort Button to a gallery or just change the sorting / Canvas App

(1) ShareShare
ReportReport
Posted on by 4

Hi all,

 

i created a power app and want to change the sorting for the field on the left - I already  tried everything i read online but its just not working. The empty slots from the sharepoint list are at the top which should change to the newest entry at the top:

mat5_0-1721047982725.png

 

mat5_1-1721048085611.png

 

The coding for the gallery is set up like this if this helps:

 

- RecordsGallery1:
Control: Gallery
Variant: BrowseLayout_Vertical_ThreeTextVariant_ver5.0
Properties:
OnSelect: =
Default: =CurrentItem
Items: ='Genehmigungen Debitoren'
DelayItemLoading: =true
Fill: =RGBA(250, 250, 250, 1)
Layout: =Layout.Vertical
LayoutMinWidth: =0
LoadingSpinner: =LoadingSpinner.Data
TemplateFill: =If(ThisItem.IsSelected, RGBA(230, 230, 230, 1), RGBA(0, 0, 0, 0))
TemplatePadding: =0
TemplateSize: =104
ZIndex: =1
Children:
- Title1_2:
Control: Label
Properties:
OnSelect: =Select(Parent)
Text: =ThisItem.'Angefordert von'
FontWeight: =If(ThisItem.IsSelected, FontWeight.Semibold, FontWeight.Normal)
Height: =26
PaddingBottom: =0
PaddingLeft: =12
PaddingRight: =0
PaddingTop: =0
Size: =8
VerticalAlign: =VerticalAlign.Top
Width: =196
X: =153
Y: =16
- Title1_1:
Control: Label
Properties:
OnSelect: =Select(Parent)
Text: =ThisItem.Erstellt
FontWeight: =If(ThisItem.IsSelected, FontWeight.Semibold, FontWeight.Normal)
Height: =18
PaddingBottom: =0
PaddingLeft: =12
PaddingRight: =0
PaddingTop: =0
Size: =10
VerticalAlign: =VerticalAlign.Top
Width: =121
X: =197
Y: =67
- Rectangle1:
Control: Rectangle
Properties:
OnSelect: =Select(Parent)
Height: =Parent.TemplateHeight - Separator1.Height
Visible: =ThisItem.IsSelected
Width: =4
- Separator1:
Control: Rectangle
Properties:
OnSelect: =Select(Parent)
Fill: =RGBA(255, 255, 255, 1)
Height: =8
Width: =Parent.TemplateWidth
Y: =Parent.TemplateHeight - Self.Height
- NextArrow1:
Control: Classic/Icon
Variant: ChevronRight
Properties:
OnSelect: =Select(Parent)
AccessibleLabel: =Self.Tooltip
Tooltip: ="Elementdetails anzeigen"
Color: =RGBA(166, 166, 166, 1)
Height: =50
Icon: =Icon.ChevronRight
PaddingBottom: =16
PaddingLeft: =16
PaddingRight: =16
PaddingTop: =16
Width: =50
X: =Parent.TemplateWidth - Self.Width - 12
Y: =(Parent.TemplateHeight / 2) - (Self.Height / 2)
- Body1:
Control: Label
Properties:
OnSelect: =Select(Parent)
Text: =ThisItem.Kundennummer
FontWeight: =If(ThisItem.IsSelected, FontWeight.Semibold, FontWeight.Normal)
Height: =Self.Size * 1.8
PaddingBottom: =0
PaddingLeft: =12
PaddingRight: =0
PaddingTop: =0
VerticalAlign: =VerticalAlign.Top
Width: =Title1.Width
X: =Title1.X
Y: =Subtitle1.Y + Subtitle1.Height
- Subtitle1:
Control: Label
Properties:
OnSelect: =Select(Parent)
Text: =ThisItem.Kundenname
FontWeight: =If(ThisItem.IsSelected, FontWeight.Semibold, FontWeight.Normal)
Height: =Self.Size * 1.8
PaddingBottom: =0
PaddingLeft: =12
PaddingRight: =0
PaddingTop: =0
VerticalAlign: =VerticalAlign.Top
Width: =Title1.Width
X: =Title1.X
Y: =Title1.Y + Title1.Height
- Title1:
Control: Label
Properties:
OnSelect: =Select(Parent)
Text: =ThisItem.Titel
FontWeight: =If(ThisItem.IsSelected, FontWeight.Semibold, FontWeight.Normal)
Height: =Self.Size * 1.8
PaddingBottom: =0
PaddingLeft: =12
PaddingRight: =0
PaddingTop: =0
VerticalAlign: =VerticalAlign.Top
Width: =Parent.TemplateWidth - 86
X: =16
Y: =(Parent.TemplateHeight - (Self.Size*1.8 + Subtitle1.Size*1.8 + 2 + Body1.Size*1.8)) / 2

 

 

 

  • Ami K Profile Picture
    15,665 Super User 2024 Season 1 on at
    Re: Adding a sort Button to a gallery or just change the sorting / Canvas App

    @mat5 - looks like the operators for your region are different. Could you try:

     

    Sort(
     'Genehmigungen Debitoren';
     Modified;
     If(
     ctx_sort;
     SortOrder.Ascending;
     SortOrder.Descending
     )
    )
  • mat5 Profile Picture
    4 on at
    Re: Adding a sort Button to a gallery or just change the sorting / Canvas App

    This is before 

    mat5_0-1721131308573.png

    This is after:

    mat5_1-1721131384661.png

     

  • Ami K Profile Picture
    15,665 Super User 2024 Season 1 on at
    Re: Adding a sort Button to a gallery or just change the sorting / Canvas App

    @mat5 - could you apply the code I gave you (point 3) into the Items property of the Gallery and then take screenshot of what happens/any errors.

  • mat5 Profile Picture
    4 on at
    Re: Adding a sort Button to a gallery or just change the sorting / Canvas App

    Hi Amik,

    Thanks for the fast response!

    I deleted the default and added the "UpdateContext" to the button. But the 3. is not working - maybe I'm on the wrong component? On the RecordsGallery1 in "Items" is 'Genehmigungen Debitoren' mentioned, when i delete this, no info is shown anymore in the list. I tried to change this 'Genehmigungen Debitoren' to your third point.

    mat5_0-1721115811923.png

    mat5_1-1721115892298.png

     

     

  • Ami K Profile Picture
    15,665 Super User 2024 Season 1 on at
    Re: Adding a sort Button to a gallery or just change the sorting / Canvas App

    @mat5  -

    1. Clear whatever you have in the Default property of the Gallery.

    2. On the OnSelect property of your Button control, create a Local Context Variable:

     

    UpdateContext({ctx_sort: !ctx_sort})​

     

    3. On the Items property of the Gallery control, use:

     

    Sort(
     'Genehmigungen Debitoren',
     Modified,
     If(
     ctx_sort,
     SortOrder.Ascending,
     SortOrder.Descending
     )
    )​

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

🌸 Community Spring Festival 2025 Challenge 🌸

WIN Power Platform Community Conference 2025 tickets!

Markus Franz – Community Spotlight

We are honored to recognize Markus Franz as our April 2025 Community…

Kudos to the March Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 146,524 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,906 Most Valuable Professional

Leaderboard