Power BI is a fantastic tool for visualizing data — and you can easily integrate live weather data into your reports too. In this blog, we’ll walk you through the process of building a real-time weather dashboard powered by WeatherAPI, and then we’ll add some Air Quality Index (AQI) indicators for a richer dashboard experience.
🎯 Why WeatherAPI?
WeatherAPI.com is a simple and powerful service that returns live, historical, and forecast weather data — perfect for Power BI. The data is available in JSON format, making it easy to process and transform.
🛠️ Prerequisites
✅ A free or paid account on WeatherAPI.com
✅ Power BI Desktop installed
✅ Basic Power BI data model knowledge
🔑 Step 1: Get Your WeatherAPI Key
Sign up at WeatherAPI.com, then copy your API key.
You’ll use this key to authenticate API calls.
🌐 Step 2: Build the API URL
For current weather data, use:
🧠 Step 3: Connect Power BI to WeatherAPI
Open Power BI Desktop.
Click Get Data → Web.
Enter your WeatherAPI URL.
Click OK.
🧹 Step 4: Transform the Data
Power BI will show a preview in the Power Query Editor:
Expand the
currentrecord.Expand sub-records like
conditionorair_quality.Rename columns for clarity.
Click Close & Apply.
📊 Step 5: Build Your Dashboard
Add:
✅ Cards for temperature, humidity, etc.
✅ Gauges for wind speed.
✅ Charts for daily variations.
And you can also set up filters/slicers for different cities.
🎨 Step 6: Styling & Interactivity
Insert icons representing the current weather.
Plot the map visual with city locations.
Allow your users to select cities dynamically.
⚡ Step 7: Adding AQI Indicators with Reusable Measures
You can easily incorporate Air Quality Index (AQI) data into your report using the current.air_quality part of the WeatherAPI response.
Here’s a quick Power BI DAX pattern you can copy-paste and adapt to your needs:
🎨 Generic Template for AQI Color:
💡 Simply copy this measure and replace COLUMN_NAME with the air quality column you want to check — for example:
pm2_5cono2
🎨 Generic Template for AQI Suggestion:
🎨 Generic Template for AQI Status:
✅ Again, just replace COLUMN_NAME with the pollutant of interest.
All Power BI Measures:
Curr_Temp_C = SUM('Current'[current.temp_c]) & " °C"
Curr_Temp_f = SUM('Current'[current.temp_f]) & " °F"
last_update = "Last Updated, " & FORMAT(FIRSTNONBLANK('Current'[current.last_updated], ""), "dd mmm")
For_Temp_C = AVERAGE(Forcast_Day[forecast.forecastday.day.avgtemp_c]) & " °C"
AQI_Status_Text =
VAR AQI = ROUND(SELECTEDVALUE('Current'[current.air_quality.pm10]),0)
RETURN SWITCH(
TRUE(),
AQI <= 50, "Good",
AQI <= 100, "Moderate",
AQI <= 150, "Unhealthy for Sensitive",
AQI <= 200, "Unhealthy",
AQI <= 300, "Very Unhealthy",
"Hazardous"
)
AQI_Color_PM10 =
VAR AQI = ROUND(SELECTEDVALUE('Current'[current.air_quality.pm10]),0)
RETURN SWITCH(
TRUE(),
AQI <= 50, "#43d946", -- Good (Green)
AQI <= 100, "#fff570", -- Moderate (Yellow)
AQI <= 150, "#ff9800", -- Poor (Orange)
AQI <= 200, "#d99343", -- Unhealthy (Red)
AQI <= 300, "#ff5b0f", -- Severe (Purple)
"#d95243" -- Hazardous (Dark Maroon)
)
AQI_Suggestion =
VAR AQI = SELECTEDVALUE('Current'[current.air_quality.pm10])
RETURN SWITCH(
TRUE(),
AQI <= 50, "Air is clean and healthy",
AQI <= 100, "Acceptable air quality, stay active",
AQI <= 150, "Sensitive groups should reduce outdoor time",
AQI <= 200, "Limit prolonged outdoor exertion",
AQI <= 300, "Avoid outdoor activity if possible",
"Stay indoors, wear mask if outside"
)
Left_Rain_Chance = 100 - SUM(Forcast_Day[forecast.forecastday.day.daily_chance_of_rain])
avg_day_Temp_c = SUM(Forcast_Day[forecast.forecastday.day.avgtemp_c])
avg_hour_Temp_c = SUM(Forcast_Hour[forecast.forecastday.hour.temp_c])
PM10_Left = 300 - SUM('Current'[current.air_quality.pm10])
AQI_Color_CO =
VAR AQI = ROUND(SELECTEDVALUE('Current'[current.air_quality.co]),0)
RETURN SWITCH(
TRUE(),
AQI <= 50, "#43d946",
AQI <= 100, "#fff570",
AQI <= 150, "#ff9800",
AQI <= 200, "#d99343",
AQI <= 300, "#ff5b0f",
"#d95243"
)
AQI_Color_SO2 =
VAR AQI = ROUND(SELECTEDVALUE('Current'[current.air_quality.so2]),0)
RETURN SWITCH(
TRUE(),
AQI <= 50, "#43d946",
AQI <= 100, "#fff570",
AQI <= 150, "#ff9800",
AQI <= 200, "#d99343",
AQI <= 300, "#ff5b0f",
"#d95243"
)
AQI_Color_O3 =
VAR AQI = ROUND(SELECTEDVALUE('Current'[current.air_quality.o3]),0)
RETURN SWITCH(
TRUE(),
AQI <= 50, "#43d946",
AQI <= 100, "#fff570",
AQI <= 150, "#ff9800",
AQI <= 200, "#d99343",
AQI <= 300, "#ff5b0f",
"#d95243"
)
AQI_Color_NO2 =
VAR AQI = ROUND(SELECTEDVALUE('Current'[current.air_quality.no2]),0)
RETURN SWITCH(
TRUE(),
AQI <= 50, "#43d946",
AQI <= 100, "#fff570",
AQI <= 150, "#ff9800",
AQI <= 200, "#d99343",
AQI <= 300, "#ff5b0f",
"#d95243"
)
AQI_Color_PM2_5 =
VAR AQI = ROUND(SELECTEDVALUE('Current'[current.air_quality.pm2_5]),0)
RETURN SWITCH(
TRUE(),
AQI <= 50, "#43d946",
AQI <= 100, "#fff570",
AQI <= 150, "#ff9800",
AQI <= 200, "#d99343",
AQI <= 300, "#ff5b0f",
"#d95243"
)
Humidity = SUM('Current'[current.humidity]) & " %"
Wind_Speed = SUM('Current'[current.wind_kph]) & " Kph"
Visibility = SUM('Current'[current.vis_km]) & " KM"
Pressure = SUM('Current'[current.pressure_mb]) & " mm"
UV_Index = SUM('Current'[current.uv])
Precipitation = SUM('Current'[current.precip_mm]) & " mm"
💡 Quick Tip:
Keep these generic DAX measures as templates — so when you want to add AQI visualizations for new pollutants like so2, no2, or o3, you only need to copy-paste and tweak one column name.
🎉 Conclusion
By integrating WeatherAPI into Power BI, you can create a dynamic weather dashboard with live data, then enrich it with custom AQI visualizations — all in a few easy steps. With these reusable DAX measures, your dashboard stays scalable, maintainable, and easy to enhance as your requirements grow.
Happy dashboarding! 🎨

