Home and Learn: Power BI 2023


Power BI and Dates

Power BI dashboards tend to have date information somewhere. In this lesson, you'll learn how to work with dates.

Download the following spreadsheet.

Widget Sales Data

It only has three columns, one for the item, one for the number of items ordered, and one for the date the item was ordered.

Open Power BI. Click File > Get Data. The file you downloaded was an Excel file, so select the Excel Workbook option to load. You'll soon be looking at this screen:

The Power BI Navigator screen showing a spreadsheet ready to load.

Click the Load button. In Power BI, have a look at the Data panel on the right:

Power BI Data panel

(If you can't see a Data panel, click View from the Power BI ribbons at the top of the screen. From the View menu, toggle the Data item, which is on the Show Panes panel.)

Notice that Order Date item is expandable. Expand the item to see that Power BI has added a Date Hierarchy item. Expand this to see the following:

An expanded date hierarchy in Power BI 2023.

The Order_Date Column is coming from our dataset. Power BI has extracted date parts all by itself. It has extracted a Year, a Quarter, a Month, and a Day. Let's see what these look like.

Add a Table visual to your dashboard:

The table visual icon in Power BI 2023.

The default table looks like this:

Power BI table default

From the flyout, click the Add Data button. Select the Month item from the Date Hierarchy:

Add a Month column to the Power BI table visual.

Your table will then have the months in the first column:

A Power BI table with months in the first column.

Click the Add Data button again. This time, select the Units Sold item:

Add a second column to the table.

And here's your table:

Power BI tble with two columns.

You can change which date part is displayed in the first column. Let's change the first column from Month to Quarter.

Click the Data Options arrow, indicated in the image below:

Arrow pointing to the Data Options.

This will bring up another flyout - Data. From this Data flyout, click the dropdown to see a list of your dataset columns again. Select the Quarter item:

Changing the date of a table to Quarters.

Now delete the Month by clicking the X under Columns, as indicated in the image below:

Arrow pointing to the delete column option.

Your table will then show just the quarters:

Power BI table showing just the yearly quarters.

Using the same technique, turn the Quarters column into Day. Your table will look like this, if you're successful:

Power BI table visual with the Days as the first column.

This is not very useful, as it just shows us the day numbers. What would be better if the days were named days, like Monday, Tuesday, etc. Then we could see if any days were better or worse than others. Perhaps one day is particularly bad for sales and we could either close that day, or reduce the number staff working on the bad days.

 

Days of the Week

In order to get named days, we need Power Query again.

To get Power Query back, right-click the table name in the Data panel on the right of Power BI.

Arrow pointing to the top item in the Power BI Data panel, indicating where to right-click.

You'll see this menu appear:

Context menu in Power BI showing the Edit Query item highlighted.

From the menu, select Edit Query. This will launch Power Query.

In Power Query, select just the Order_Date column. From the menus at the top, select Add Column. From the Add Column menu, locate the From Date & Time panel and the Date item:

The Date item highlighted in Power Query.

From the Date dropdown menu, select Day > Name of Day:

The Power Query Date menu with the Name of Day item highlighted.

When you select Name of Day, a new column will be added to your table:

A Day Name column added in Power Query.

From the menus at the top of Power Query, click Close & Apply. Power Query will close and the new column and its data will appear in the Data area of Power BI:

The Power BI Date panel with a new Day Name column added.

In your table, change the Day column to Day Name, using the same techniques as above. Your table will then look like this:

A Power BI table visual with the days of the week in the first column.

OK, that's better. Now we can see that Friday and Saturday are our slowest sales days. Perhaps we can trim a worker on a Friday!

 

We'll continue this lesson on new page. Click the link below to go to the next lesson, which is on Date Slicers.

<--Back to the Power BI Contents Page

 


Email us: enquiry at homeandlearn.co.uk