This Power Apps tutorial will explain how to sort a Power Apps gallery by day. Like, how to sort a Power Apps gallery by the current day and sorting a Power Apps gallery by the next day, and how to sort a Power Apps gallery by the next ‘N’ days.
In the last, I will cover sorting a Power Apps gallery by the previous day and how to sort a Power Apps gallery by the last ‘N’ days.
Power Apps Sort Gallery By Day [Current Day]
Here, we will discuss how to sort a Power Apps gallery by the current day with a simple example.
Example:
I have a SharePoint Online list, i.e., [Product Details] and this list contains the below fields.
Column Name | Data Type |
Product Name | Default single line of text |
Manufacturer | Choice |
Price | Currency |
Purchase Date | Date and time |

Now, I want to sort the Power Apps gallery records [Ascending] from the SharePoint Online list, as in the screenshot below.

To achieve the above example, follow the below-mentioned steps. Such as:
1. Open Power Apps -> Create a Blank canvas app and connect it to the SharePoint list as shown below.

2. Then, insert a Gallery control [gal_Products] and set its Items property to the code below.
Items = With(
{
StartDate: Today(),
EndDate: Today() + 1
},
SortByColumns(
Filter(
'Product Details',
'Purchase Date' >= StartDate,
'Purchase Date' < EndDate
),
"Title",
SortOrder.Ascending
)
)
Where,
- With() = This function can help us to evaluate a formula for a single record
- StartDate, EndDate = Power Apps scope variables
- Today() = Power Apps Today() helps to get the current date
- ‘Product Details’ = SharePoint Online list
- ‘Purchase Date’ = SharePoint date and time field
- “Title” = SharePoint text field

3. Save, Publish, and Preview the app. The Power Apps gallery sort and display each record from a SharePoint list as in the screenshot below.

This is how to sort a Power Apps gallery by current day/ today.
Power Apps Sort Gallery By Next Day
Next, we will see how to sort a Power Apps gallery by the next day.
Example:
I will also take the same SharePoint online list [Product Details] for this example. In Power Apps, there is a gallery control. This gallery sort and display each record from a SharePoint list based on the next day [Descending Order] like below.

To do so, follow the steps.
1. On the Power Apps Screen -> Insert a Power Apps gallery and set its Items property as:
Items = With(
{
StartDate: Today(),
EndDate: Today() + 1
},
Sort(
Filter(
'Product Details',
'Purchase Date' > StartDate,
'Purchase Date' <= EndDate
),
Title,
SortOrder.Descending
)
)
Where,
- StartDate, EndDate = Power Apps Scope Variables
- Today() + 1 = Tomorrow’s Date

2. Save, Publish, and Preview the app. The gallery sort and display each record from a SharePoint list based on the tomorrow as shown below.

This is how to sort a Power Apps gallery by the next day.
Power Apps Sort Gallery By Next ‘N’ Days
Similarly, we will discuss how to sort a Power Apps gallery by the next 2 days.
In this example, I will also take the above SharePoint Online list and I want to sort the Power Apps gallery records based on the next two days. I have used the code below in the Gallery’s Items property.
Items = With(
{
StartDate: Today(),
EndDate: Today() + 2 // You can also change the number of days
},
SortByColumns(
Filter(
'Product Details',
'Purchase Date' >= StartDate,
'Purchase Date' <= EndDate
),
"Title",
SortOrder.Ascending
)
)
Where,
- Today() + 2 = Today() function helps to get the current date. And 2 is the number of weekdays.

Save, publish, and Preview the app. The gallery will sort and display each record from the SharePoint list based on the next 2 days as in the screenshot below.

This is how to sort a Power Apps gallery by the next two days.
Power Apps Sort Gallery by Last Day
Let’s see how to sort a Power Apps gallery by the last day. Here, I will also take the same SharePoint list for this example.
In Power Apps, there is a Gallery control. This gallery will sort and display SharePoint list records based on yesterday. For that, follow the below Gallery’s Items property code:
Items = With(
{
StartDate: Today() - 1,
EndDate: Today()
},
SortByColumns(
Filter(
'Product Details',
'Purchase Date' >= StartDate,
'Purchase Date' < EndDate
),
"Title",
SortOrder.Ascending
)
)
Where,
- Today()-1 = Yesterday’s Date

Now, whenever the user opens a gallery control, it will sort and display each record from a SharePoint list based on the last day, as shown below.

This is how we can sort a Power Apps gallery by yesterday/last day.
Power Apps Sort Gallery By Last ‘N’ Days
I will show you how to sort a Power Apps gallery by the last 3 days.
Example:
I will also use the same SharePoint Online list [Product Details] for this example. In Power Apps, there is a Gallery control. This gallery will sort and display each record from a SharePoint list based on the last 3 days.
For that, I have used the below-mentioned code in the Gallery Items property:
Items = SortByColumns(
Filter(
'Product Details',
'Purchase Date' >= DateAdd(
Today(),
-3, // You can also change the number of days
TimeUnit.Days
)
),
"Title",
SortOrder.Ascending
)
Where,
- ‘Product Details’ = SharePoint list
- DateAdd() = This function adds a number of units to a Date/Time column
- -3 = Number of Previous Days

Once your app is ready, Save, Publish, and Preview the app. The gallery will sort and display SharePoint list records based on the last 3 days, as in the screenshot below.

This is all about sorting a Power Apps gallery by the last 3 days.
Conclusion
I trust this Microsoft Power Apps tutorial explained everything about how to sort a Power Apps gallery by day. Like:
- Power App sort gallery by current day
- How to sort a Power Apps gallery by the next day
- Sorting a Power Apps gallery by the last day
- How to sort a Power Apps gallery by next ‘N’ days
- Working with Power Apps sort a gallery by the last ‘N’ days
You may also like:
- How to Sort Power Apps Gallery By ID?
- Power Apps Filter Gallery By Last Week
- How to Sort Gallery by Person Column in Power Apps?
- How to Sort Power Apps Gallery By Month
- Power Apps Sort Gallery By Calculated Field
- How to Get Row Number in Power Apps Gallery?
I am Bijay a Microsoft MVP (10 times – My MVP Profile) in SharePoint and have more than 17 years of expertise in SharePoint Online Office 365, SharePoint subscription edition, and SharePoint 2019/2016/2013. Currently working in my own venture TSInfo Technologies a SharePoint development, consulting, and training company. I also run the popular SharePoint website EnjoySharePoint.com