Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Sort gallery by month.

(0) ShareShare
ReportReport
Posted on by

Hello Guys,

 

New powerapps user here, I Would like to get help on how can I insert sorting codes on my current formula on my Gallery view.

 

If(
varDatacount < VarDelegationLimit,

Filter(
Filter(
'Luzon NAFS Dacion',
STATUS.Value = ComboBox1.Selected.Value || ComboBox1.Selected.Value = Blank()),

FilterByNameDacion.Text in Title || FilterByNameDacion.Text in STATUS.Value || FilterByNameDacion.Text in 'ACCOUNT NAME'),
Filter(
'Luzon NAFS Dacion',
STATUS.Value = ComboBox1.Selected.Value || ComboBox1.Selected.Value = Blank())

)

 



 

nmlsanmiguel_0-1681289230747.png

 

 

Hoping for your kind assistance.

 

Thank you and Stay Safe!

  • WarrenBelz Profile Picture
    146,596 Most Valuable Professional on at
    Re: Sort gallery by month.

    @nmlsanmiguel ,

    If you set up two dates with the start and end of the current month, you can query between them - First of month is

    Date(
     Year(Now()),
     Month(Now()),
    )

    Last day of month (a bit trickier)

    If(
     Month(Now()) = 12,
     Date(
     Year(Now() + 1),
     1,
     1
     ) -1,
     Date(
     Year(Now()),
     Month(Now() + 1),
     1
     ) - 1
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • nmlsanmiguel Profile Picture
    on at
    Re: Sort gallery by month.

    oh no, How can I make it delegable? Thank you

  • WarrenBelz Profile Picture
    146,596 Most Valuable Professional on at
    Re: Sort gallery by month.

    Hi @nmlsanmiguel ,

    Note this is not Delegable

    Month(YourDateField) = Month(Now()) && Year(YourDateField) = Year(Now())
  • nmlsanmiguel Profile Picture
    on at
    Re: Sort gallery by month.

    This code works for me! Thank you.

     

     

     Would also like to know if how can I filter dates automatically for the current month? Thank you. 

  • WarrenBelz Profile Picture
    146,596 Most Valuable Professional on at
    Re: Sort gallery by month.

    @nmlsanmiguel ,

    There is no Sort criteria in that code and I do not see any error lines - have you typed the full code in ?

  • nmlsanmiguel Profile Picture
    on at
    Re: Sort gallery by month.

    Hi Sir, I am Still getting an error upon doing,

     

    nmlsanmiguel_0-1681350751617.png

     

  • WarrenBelz Profile Picture
    146,596 Most Valuable Professional on at
    Re: Sort gallery by month.

    Hi @nmlsanmiguel ,

    I am not sure what you mean - you just need to replace YourSortField with your field name (and also the direction)

  • nmlsanmiguel Profile Picture
    on at
    Re: Sort gallery by month.

    Hi Sir, appreciate the help, but when I am trying the IF code you have shared, I can't find the Sort Field which was a Date column. Thank you.

  • Verified answer
    WarrenBelz Profile Picture
    146,596 Most Valuable Professional on at
    Re: Sort gallery by month.

    Hi @nmlsanmiguel ,

    The problem you have here is that while you have that in filter in the statement, the query is not Delegable, so you might as well do this

    With(
     {
     wData:
     Filter(
     'Luzon NAFS Dacion',
     STATUS.Value = ComboBox1.Selected.Value || 
     ComboBox1.Selected.Value = Blank()
     )
     },
     Sort(
     Filter(
     wData,
     FilterByNameDacion.Text in Title || 
     FilterByNameDacion.Text in STATUS.Value || 
     FilterByNameDacion.Text in 'ACCOUNT NAME'
     ),
     YourSortField,
     YourSortDirection
     )
    )
    

    You can try this as well

    If(
     varDatacount < VarDelegationLimit,
     Sort(
     Filter(
     'Luzon NAFS Dacion'
     STATUS.Value = ComboBox1.Selected.Value || 
     ComboBox1.Selected.Value = Blank()
     ),
     YourSortField,
     YourSortDirection
     ),
     Sort(
     Filter(
     'Luzon NAFS Dacion'
     (	 
     STATUS.Value = ComboBox1.Selected.Value || 
     ComboBox1.Selected.Value = Blank()
     ) &&
     (
     FilterByNameDacion.Text in Title || 
     FilterByNameDacion.Text in STATUS.Value || 
     FilterByNameDacion.Text in 'ACCOUNT NAME'
     )
     ),
     YourSortField,
     YourSortDirection
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

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,596 Most Valuable Professional

#2
RandyHayes Profile Picture

RandyHayes 76,287 Super User 2024 Season 1

#3
Pstork1 Profile Picture

Pstork1 65,928 Most Valuable Professional

Leaderboard