Create a Custom Calendar in Power Apps

Recently, I built a custom calendar in Power Apps to organize their schedule better for a client. Instead of using the usual calendar tools, we built a Power Apps calendar using various galleries and variables. This approach made it easier to display events and interact with dates directly within the app.

In this article, I will explain how to create a custom calendar in Power Apps using a step-by-step process.

So let’s get started!

Create a Custom Calendar in Power Apps

In this example, I will show you a Power Apps calendar control that displays the current date, the previous month, the next month, and weekends.

Refer to the GIF below:

Power Apps Custom Calendar
  1. Create a Power Apps blank canvas app and add a label to the screen for a header. You can provide some header text using the Label’s Text property:
"POWER APPS CUSTOM CALENDAR"
PowerApps Custom Calendar
  1. Select the Power Apps screen and apply the code below to its OnVisible property:
Set(
    UserdateSelected,
    Now()
);
Set(
    FirstDayOfMonth,
    DateAdd(
        UserdateSelected,
        1 - Day(UserdateSelected),
        TimeUnit.Days
    )
);
Set(
    firstDayInView,
    DateAdd(
        FirstDayOfMonth,
        -(Weekday(FirstDayOfMonth) - 2 + 1),
        TimeUnit.Days
    )
);
Set(
    LastDayOfMonth,
    DateAdd(
        DateAdd(
            FirstDayOfMonth,
            1,
            TimeUnit.Months
        ),
        -1,
        TimeUnit.Days
    )
);
Set(
    MinDate,
    DateAdd(
        FirstDayOfMonth,
        -(Weekday(FirstDayOfMonth) - 2 + 1),
        TimeUnit.Days
    )
);
Set(
    MaxDate,
    DateAdd(
        DateAdd(
            FirstDayOfMonth,
            -(Weekday(FirstDayOfMonth) - 2 + 1),
            TimeUnit.Days
        ),
        35,
        TimeUnit.Days
    )
);

Where,

UserdateSelected, FirstDayOfMonth, firstDayInView, LastDayOfMonth, MinDate, MaxDate = Variable Names

Power Apps Create Custom Calendar
  1. Add a Rectangle shape (Insert -> Shape -> Rectangle) below the header and insert a forward and a backward icon like the image below.
Custom Calendar in Power Apps

Select the backward icon (<) and apply the code below to its OnSelect property:

Set(
    FirstDayOfMonth,
    DateAdd(
        FirstDayOfMonth,
        -1,
        TimeUnit.Months
    )
);
Set(
    firstDayInView,
    DateAdd(
        FirstDayOfMonth,
        -(Weekday(FirstDayOfMonth) - 2 + 1),
        TimeUnit.Days
    )
);
Set(
    LastDayOfMonth,
    DateAdd(
        DateAdd(
            FirstDayOfMonth,
            1,
            TimeUnit.Months
        ),
        -1,
        TimeUnit.Days
    )
);
If(
    MinDate > FirstDayOfMonth,
    Set(
        MinDate,
        FirstDayOfMonth
    )
);

FirstDayOfMonth, firstDayInView, LastDayOfMonth, MinDate = Variable names

Custom Calendar in PowerApps

Select the forward icon (>) and apply the code below to its OnSelect property:

Set(
    FirstDayOfMonth,
    DateAdd(
        FirstDayOfMonth,
        1,
        TimeUnit.Months
    )
);
Set(
    firstDayInView,
    DateAdd(
        FirstDayOfMonth,
        -(Weekday(FirstDayOfMonth) - 2 + 1),
        TimeUnit.Days
    )
);
Set(
    LastDayOfMonth,
    DateAdd(
        DateAdd(
            FirstDayOfMonth,
            1,
            TimeUnit.Months
        ),
        -1,
        TimeUnit.Days
    )
);
If(
    LastDayOfMonth > MaxDate,
    Set(
        MaxDate,
        LastDayOfMonth
    )
);
Custom Calendar PowerApps
  1. To display the month and year, insert a Label over the rectangle and set its Text property as:
Text(FirstDayOfMonth, "[$-en-US]mmmm yyyy")
Custom Calendar Power Apps
  1. Next, add a Blank horizontal gallery below the rectangle.
Make A Calendar In Power Apps

Select the gallery and set its Items property as:

Calendar.WeekdaysShort()
Make Calendar In Power Apps
  1. Inside the gallery, add a label and set its Text property as:
ThisItem.Value

All the day names (Sun, Mon, etc.) will appear on the label, as shown below.

make Power Apps Calendar
  1. To set the weekend as a different color, select the label and set its Fill property as:
Fill = If(
    ThisItem.Value = "Sun" || ThisItem.Value = "Sat",
    Color.Azure,
    Color.Beige
)

You can provide any color you want.

make PowerApps Calendar
  1. Add a Blank vertical gallery under the days and set its Wrap count property to 7.
calendar powerapps
  1. Edit the gallery and set its Items property as:
[
    "0",
    "1",
    "2",
    "3",
    "4",
    "5",
    "6",
    "7",
    "8",
    "9",
    "10",
    "11",
    "12",
    "13",
    "14",
    "15",
    "16",
    "17",
    "18",
    "19",
    "20",
    "21",
    "22",
    "23",
    "24",
    "25",
    "26",
    "27",
    "28",
    "29",
    "30",
    "31",
    "32",
    "33",
    "34"
]
power apps calendar control
  1. Again, edit the gallery and insert a label inside it. Apply the formula below to its Text property as:
Day(
    DateAdd(
        firstDayInView,
        Value(ThisItem.Value),
        TimeUnit.Days
    )
)
powerapps calendar control
  1. Edit the gallery and add a rectangle shape inside it. Select the rectangle, click on ellipses, reorder, and send it backward, so that it goes back to the gallery label.
power apps calendar
  1. Apply the code below to the rectangle’s BorderThickness property:
If(
    DateAdd(
        firstDayInView,
        Value(ThisItem.Value)
    ) = UserdateSelected,
    3,
    1
)
powerapps calendar view
  1. Again, go to the Rectangle Fill property and apply the code below:
If(
    Abs(Label4.Text - ThisItem.Value) > 10,
    Color.LightGray,
    Color.DarkGray
)

Where,

Label4 = Label name that shows the date inside the gallery

Create Custom Calendar in Power Apps

Finally, the Power Apps custom calendar will look like the screenshot below. Save, publish, and preview the app. Once you click on the forward icon, it will show you the upcoming dates and days.

In the same way, clicking on the backward icon will show you the previous month’s dates and days. Additionally, if you hover over any dates, the hover background color will change to blue (you can see the top gif).

Create a Custom Calendar in Power Apps

I hope this article helped you learn how to create a custom calendar in Power Apps by creating variables and using controls like galleries, labels, rectangles, etc.

Additionally, you may like some more Power Apps tutorials:

  • >

    Build a High-Performance Project Management Site in SharePoint Online

    User registration Power Apps canvas app

    DOWNLOAD USER REGISTRATION POWER APPS CANVAS APP

    Download a fully functional Power Apps Canvas App (with Power Automate): User Registration App

    Power Platform Tutorial FREE PDF Download

    FREE Power Platform Tutorial PDF

    Download 135 Pages FREE PDF on Microsoft Power Platform Tutorial. Learn Now…