Skip to main content

How to Add Previous and Next Month Buttons in Power Apps

· 7 min read
Jagdish Kumawat
Founder @ Dewiride

A screen that shows one month at a time needs a way to move between months. Keep the month in a context variable, as its first day; two buttons move it with DateAdd(month, -1, TimeUnit.Months) and DateAdd(month, 1, TimeUnit.Months), and a heading shows it as November 2026. To stop people going past this month, the next button disables itself there.

The example is the Overtime Timesheet app's My Overtime screen, which shows each person's overtime month by month.

Prerequisites​

Step 1: Start on This Month​

The screen's OnVisible sets the month the first time the screen opens, and leaves it alone afterwards (How to Run a Formula When a Screen Opens in Power Apps with OnVisible):

My Overtime Screen → OnVisible (first part)
If(
IsBlank(locMonthMO),
UpdateContext({locMonthMO: Date(Year(Today()), Month(Today()), 1)})
);

A context variable holds its value until the app is closed (UpdateContext), so someone who goes to another screen and comes back is still on the month they chose.

Step 2: Add the Bar​

Insert a Horizontal container, conMonthMO, with three controls in it:

ControlWhat it is
btnPreviousMonthMOA button with only a left chevron
lblMonthMOA Text control with the month's name, filling the space between
btnNextMonthMOA button with only a right chevron

The container: Flexible height off, Height 40, Width Min(640, Parent.Width - 48), Align (vertical) centre, Gap 8.

The two buttons:

PropertybtnPreviousMonthMObtnNextMonthMO
Text"Previous month""Next month"
Icon"ChevronLeft""ChevronRight"
LayoutButtonLayout.IconOnlyButtonLayout.IconOnly
AppearanceButtonAppearance.SecondaryButtonAppearance.Secondary
Width, Height40, 4040, 40
AccessibleLabel, Tooltip"Previous month""Next month"

With Layout set to icon only, the Text isn't shown, so AccessibleLabel tells screen readers what the button does and Tooltip tells mouse users.

The heading, with FillPortions 1 so it takes the space between the buttons, Align Align.Center, Size 20 and FontWeight FontWeight.Semibold:

lblMonthMO → Text
Text(locMonthMO, "mmmm yyyy")

More on the format: How to Show the Month Name and Year in Power Apps.

Step 3: Move a Month​

DateAdd with TimeUnit.Months moves a date by whole months. Each button moves the month, then reloads the screen's data, which the example keeps in its Refresh button (How to Use the Select Function in Power Apps):

btnPreviousMonthMO → OnSelect
UpdateContext({locMonthMO: DateAdd(locMonthMO, -1, TimeUnit.Months)});
Select(btnRefreshMO)
btnNextMonthMO → OnSelect
UpdateContext({locMonthMO: DateAdd(locMonthMO, 1, TimeUnit.Months)});
Select(btnRefreshMO)

The OnSelect property of btnPreviousMonthMO in the expanded formula bar: UpdateContext setting locMonthMO to DateAdd(locMonthMO, -1, TimeUnit.Months), then Select(btnRefreshMO)

Because the month is always its first day, moving it never skips a month or lands on a day that doesn't exist.

Step 4: Stop at This Month​

Overtime can't be logged for the future, so there's nothing to see after this month. The next button is disabled when the month shown is this month or later (How to Make a Control Read-Only in Power Apps with DisplayMode):

btnNextMonthMO → DisplayMode
If(locMonthMO < Date(Year(Today()), Month(Today()), 1), DisplayMode.Edit, DisplayMode.Disabled)

In November 2026, the current month, the preview strip shows disabled:

The DisplayMode property of btnNextMonthMO with the If formula, the preview strip reading disabled, and the month bar on the canvas with November 2026 and a greyed-out next-month button

Step 5: Try It​

Preview the app and open the screen. On this month, the next button is greyed out:

The top of the My overtime screen in Preview: the green header with Back and My overtime, and below it a previous-month button, the heading November 2026 and a greyed-out next-month button

After Previous month, the heading reads October 2026, and the next button can be used again:

The same bar after Previous month: the heading October 2026 and both buttons enabled

Common Mistakes​

MistakeWhat happensDo this instead
Keeping today's date and adding months to itThe day comes along, and not every month has a 29th, 30th or 31stKeep the first day of the month
Setting the month in OnVisible every timeThe screen jumps back to this month when people returnSet it only when it's blank
Leaving AccessibleLabel and Tooltip empty on an icon-only buttonNothing on screen says what the button doesGive each one a label and a tooltip

Troubleshooting​

SymptomLikely causeFix
The heading is empty in PreviewPreview started on this screen, so OnVisible didn't runPreview from the screen before it and go to this one
The month changes but the list doesn'tThe buttons don't reload the dataAdd the reload, such as Select(btnRefreshMO)
The next button is never enabledThe comparison is the wrong way roundlocMonthMO < first day of this month enables it for earlier months

FAQ​

Why does Preview show an empty heading?​

Microsoft's Screen control reference describes OnVisible as the behavior of an app when the user navigates to a screen. Starting Preview on the screen isn't navigating to it, so the month stays blank. Preview from the screen before it and go to this one.

Can people pick a month from a list instead?​

Yes, but two buttons are enough when people mostly look at this month and the one before.

Conclusion​

Keep the month as its first day in a context variable, move it with DateAdd(month, ±1, TimeUnit.Months) from two labelled icon buttons, show it with Text(month, "mmmm yyyy"), and disable the next button at this month.

Additional Resources​