Unlock Weather Insights: How You Can Use Power BI with OpenWeatherMap — Part 6

Andrew Hubbard
Microsoft Power BI
Published in
5 min readJan 29, 2024
Sample image from the weather dashboard we will create. Background image in dashboard Photo by Tim Foster on Unsplash

Now that we have completed importing and preparing the data we are now ready to build the dashboard. To do this, we will start by building some basic measures. The measures used in this dashboard are basic measures and will not require the creation of complex formulas as we are just formatting text and finding maximum and minimum values. Before we add visuals, we should create the measures to be used by the visuals.

Open up Power BI Desktop and then open the file that you have used in this series of posts.

Create Measure Table

It is good practice to create a table to store the measures. This keeps measures organised and easier to find than having measures stored in different tables. To create a measure table is very simple. These are the steps to create the table.

  • Click on Home to open the Home tab
  • Click the Enter Data button in the ribbon, this will open the create table window.
Power BI Create Table window.
Create table window
  • We don’t need to enter any data here, as we need an empty table.
  • In the name box, enter a name for the table. I like to use “_All Measures” as this will keep the measure table at the top of the list of tables. Which is useful if there are a lot of tables in your report..
  • Once you have entered the table name click Load. The new table will appear on the list of tables. If you have been following the steps in this series, your list of tables should now look similar to this.is.
Power BI list of measures.
List of tables

Creating DAX measures to be used in the report

We will start by creating the maximum and minimum temperature measures to be used by the maximum and minimum temperature cards.

The minimum & maximum temperature measures will return the minimum and maximum temperature formatted with a degree symbol and C. If you are using imperial units, you will need to change the C to an F. I will use metric units throughout the posts.

Minimum Temperature Measure

  • Click on the new “_All Measures” table to select it.
  • Select the “New Measure” button in the Table Tools ribbon. Or you can right click on the table and select New Measure from the pop-up menu that appears.
  • Now in the formula bar type in Minimum Temperature =
  • Press Shift+Enter to start a new line.
  • Then type in FORMAT(
  • Press Shift+Enter to start a new line.
  • Then enter MIN(Current Weather[temp_min]),
  • Press Shift+Enter to start a new line.
  • Now enter “#0” & UNICHAR(176)&”C”. The “#0” will show the temperature as a two-digit number. If the temperature is less than 10, then it will not show a leading zero. I don’t need to know the temperature to decimal point level but if you wished to show the temperature to one decimal place, then you can replace my ““#0” format string with “#0.0” if you are using imperial units you will need to change my format string to “##0” or “##0.0” in case the temperature breaks 100 degrees. The UNICHAR(176) puts the degree symbol into the temperature string.
  • Press Shift+Enter to start a new line.
  • enter ) to close the format function
  • Here is the completed measure.
Minimum Temperature = 
FORMAT(
MIN(
'Current Weather'[temp_min]
),
"#0"
& UNICHAR(176)
&"C"
)

Once you have created the measure press Enter to save the measure

Cleaning up _All Measure table

As we have a measure in the table, we can now delete the “Column1” Column as we no longer need it. Doing this will make the table a measure table. Prior to deleting the “Column1” column, the measure table we created is a regular table.

Top of the list of tables. Showing the measure table is a regular table

Power BI changes the symbol for the table after we delete the “Column1” column.

Top of the list of tables. Showing the measure table has changed.

To delete the “Column1” column follow the steps below.

  • expand the “_All Measures” table.
  • right click on the “Column1” column.
  • Select the “Hide” option in the pop-up menu.

In the future, I will post the completed code for the measure for you to view, after any explanations for the measure.

Maximum Temperature Measure

The maximum temperature measure is virtually identical to the minimum temperature measure we just change the column used to temp_max and give the measure a new name. So select the “_All Measures” table and select new measure from either the pop-up menu if you right clicked on the table or from the Ribbon. This is the maximum temperature measure. Adjust the format string according to your needs. We are using MIN() to get the value for the column using the Power BI row context for the current row.

Maximum Temperature = 
FORMAT(
MAX(
'Current Weather'[temp_max]
),
"#0" &
UNICHAR(176)
&"C"
)

Now we will create the feels like temperature measure to complete the measures we will use in cards at the top of the dashboard. The measure is nearly identical to the minimum and maximum temperature measures but points to a different column. Follow the previous steps to create a new measure and select and paste the measure below into the new measure.

Feels Like Temperature = 
FORMAT(
MIN(
'Current Weather'[feels_like]
),
"#0"
& UNICHAR(176)
& "C"
)

We will now create the Temperature measure to show the current temperature in a formatted string. Again, follow the previous steps to create a new measure and select and paste the measure below into the new measure.

Current Temperature = 
FORMAT(
MIN(
'Current Weather'[temp]
),
"#0" &
UNICHAR(176)
&"C"
)

In the next part of this series, we will continue to add measures. I will make sure that the next part of this series arrives in a timely manner.

Don’t forget to subscribe to

👉 Power BI Publication

👉 Power BI Newsletter

and join our Power BI community

👉 Power BI Masterclass

--

--

Andrew Hubbard
Microsoft Power BI

A Data analyst using Microsoft Power BI to create visualisations. With a keen interest in mental well being.