Weather Analysis and Forecasting in Power BI

 Weather Analysis and Forecasting in Power BI

Dataset Description(Download Dataset)

  • Formatted Date: Timestamp of the weather observation in a readable format.

  • Summary: Short text description of the weather condition (e.g., Clear, Cloudy).

  • Precip Type: Type of precipitation recorded (e.g., rain, snow, or none).

  • Temperature (C): Actual measured air temperature in degrees Celsius.

  • Apparent Temperature (C): "Feels like" temperature considering wind and humidity.

  • Humidity: Relative humidity as a value between 0 and 1.

  • Wind Speed (km/h): Speed of the wind in kilometers per hour.

  • Wind Bearing (degrees): Wind direction in degrees (0–360, where 0 is north).

  • Visibility (km): Distance in kilometers that one can see clearly.

  • Cloud Cover: Fraction of the sky covered by clouds, ranging from 0 (clear) to 1 (overcast).

  • Pressure (millibars): Atmospheric pressure measured in millibars.

  • Daily Summary: A detailed text summary of the entire day's weather.

Problem Statement:

Accurate weather forecasting remains a challenge due to the dynamic and complex nature of atmospheric conditions. This project aims to analyze historical weather data to identify key patterns and build predictive models that can forecast weather parameters such as temperature, humidity, and precipitation with greater reliability.

Step-by-Step Guide: Weather Forecasting in Power BI

Step 1: Upload the Dataset

  1. Open Power BI Desktop.

  2. Click on Home > Get Data > Excel (or CSV).

  3. Browse and select your weather dataset file.

  4. Click Load to import the data into Power BI.

Step 2: Transform Dataset in Power Query Editor

Click Transform Data to open Power Query Editor.

  • Split Date and Time (Optional)

    • Select Formatted DateSplit Column by delimiter (space) to create Date and Time and TimeZone Offset.

  • Rename Columns

    • Correct typos like "Loud Cover""Cloud Cover" for clarity.

  • Set Data Types

    • Ensure columns like:

      • DateDate

      • Temperature, Humidity, Wind SpeedDecimal Number

      • Summary, Precip TypeText

  • Handle Missing Values

    • Use Replace Values or Remove Rows for missing/null entries.


Step 3: Add New Calculated Columns

Go to Modeling > New Column and add:

1. TempRange – Measures the difference between how it feels and actual temperature.

  • TempRange = [Apparent Temperature (C)] - [Temperature (C)]

2. ComfortIndex – Estimates discomfort due to humidity and wind.
  • ComfortIndex = 100 - ([Humidity]*100) - ([Wind Speed (km/h)]*0.5)

3. WindCategory – Labels wind speed as Calm, Breezy, Windy, or Stormy.
  • WindCategory = SWITCH(TRUE(), [Wind Speed (km/h)] < 10, "Calm", [Wind Speed (km/h)] < 20, "Breezy", [Wind Speed (km/h)] < 40, "Windy", "Stormy")

4. DayOfWeek – Extracts weekday name from the date.

  • DayOfWeek = FORMAT([Date], "dddd")


Research Questions & Power BI Steps

Q1: What is the trend of average temperature over time?

🔹 Steps to Visualize:

  1. Go to Report View.

  2. Add a Line Chart.

  3. Set:

    • X-axis: Date

    • Y-axis: Temperature (C)

  4. To find monthly or daily averages:

    • Create DAX measure:

Dax:  
AvgTemperature = AVERAGE('weatherHistory'[Temperature (C)])

Use this measure in the Y-axis instead.


In Power BI, when you drag a Date column to the X-axis, it automatically creates a date hierarchy with:

  • Year

  • Quarter

  • Month

  • Day

If You Want to Keep the Hierarchy:

You can expand/collapse the hierarchy directly on the visual:

  • Click the expand arrow () on the X-axis to drill down from Year → Quarter → Month → Day.

  • Or right-click the chart → Drill options → choose desired level.

If You Want Just One Level (e.g., Month or Date Only):

Do this:

  1. In the Fields pane, click the drop-down arrow next to Date.

  2. Select “Date” (not “Date Hierarchy”) and drag it to the X-axis.

Q2: How does apparent temperature differ from actual temperature over days?

🔹 Steps to Visualize:

  1. Use a Line Chart.

  2. Set:

    • X-axis: Date

    • Y-axis: Drag both Temperature (C) and Apparent Temperature (C)

    • Legend: Add both measures to compare

  3. Optional: Use Slicer for Month or Week.

Q3: What are the most common weather conditions (Summary)?

🔹 Steps to Visualize:

  1. Use a Pie Chart or Column Chart.

  2. Set:

    • Values: Count of Summary

    • Legend (if Pie Chart): Summary

🔹 DAX (Optional - Count):

WeatherCount = COUNT('WeatherData'[Summary])


Q4: How does humidity vary throughout the week?

🔹 Steps to Visualize:

  1. Create a column:

Dax:
DayOfWeek = FORMAT([Date], "dddd") // It is already created

In above dax query "dddd" means returns Full day, like Monday, Tuesday
if you use  "ddd" then it will return Mon, Tue, short form of day
if you use "d" it will return day like 1 or 2
if you use "dd" the it will return 01, or 02 day

2. Use a Bar Chart:

  • X-axis: DayOfWeek

  • Y-axis: AVERAGE of Humidity

Same way you can create the MonthofYear Column in modelling

MonthofYear = FORMAT([Date], "mmmm")

Perform Visualization for Month of the Year to show average Humidity


Q5: How does wind speed vary with wind direction?

🔹 Steps to Visualize:

  1. Use a Scatter Chart.

  2. Set:

    • X-axis: Wind Bearing (degrees)

    • Y-axis: Wind Speed (km/h)

  3. Optionally group bearings (e.g., N, NE, E…).

To determine the wind direction, you can create a new column called 'winddirection'.
Go to modelling and create new column, write following Dax query

WindDirection =
SWITCH(TRUE(),
    'weatherHistory'[Wind Bearing (degrees)] >= 337.5 || 'weatherHistory'[Wind Bearing (degrees)] < 22.5, "N",
    'weatherHistory'[Wind Bearing (degrees)] >= 22.5 && 'weatherHistory'[Wind Bearing (degrees)] < 67.5, "NE",
    'weatherHistory'[Wind Bearing (degrees)] >= 67.5 && 'weatherHistory'[Wind Bearing (degrees)] < 112.5, "E",
    'weatherHistory'[Wind Bearing (degrees)] >= 112.5 && 'weatherHistory'[Wind Bearing (degrees)] < 157.5, "SE",
    'weatherHistory'[Wind Bearing (degrees)] >= 157.5 && 'weatherHistory'[Wind Bearing (degrees)] < 202.5, "S",
    'weatherHistory'[Wind Bearing (degrees)] >= 202.5 && 'weatherHistory'[Wind Bearing (degrees)] < 247.5, "SW",
    'weatherHistory'[Wind Bearing (degrees)] >= 247.5 && 'weatherHistory'[Wind Bearing (degrees)] < 292.5, "W",
    'weatherHistory'[Wind Bearing (degrees)] >= 292.5 && 'weatherHistory'[Wind Bearing (degrees)] < 337.5, "NW",
    BLANK()
)

Visualize this new column as follows

Steps to Visualize Wind Speed by Wind Direction (Grouped View)

🔹 Option 1: Column Chart / Bar Chart

This is better than a scatter chart for grouped data.

  1. Go to Report View.

  2. Add a Clustered Column Chart or Bar Chart.

  3. Set:

    • X-axisWindDirection (the new grouped column)

    • Y-axisWind Speed (km/h) (aggregated automatically — default is average)

  4. (Optional) Go to the Visualizations pane → Values → Change aggregation to:

    • Average (to see typical wind speed per direction)

    • Or Max, Min, Count, etc.

Q6: Which days had low visibility and what were the corresponding weather summaries?

🔹 Steps to Visualize:

  1. Use a Table visual.

  2. Add:

    • Date

    • Visibility (km)

    • Summary

  3. Use a Filter:

    • Filter Visibility (km) less than a threshold (e.g., <5 km).

Q7: What is the relationship between cloud cover and temperature?

🔹 Steps to Visualize:

  1. Use a Scatter Chart.

  2. Set:

    • X-axis: Cloud Cover

    • Y-axis: Temperature (C)

Q8: How many days had rain or snow?

🔹 Steps to Visualize:

  1. Use a Column Chart.

  2. Set:

    • Axis: Precip Type

    • Values: Count of Precip Type

Q9: How does pressure vary with temperature?

🔹 Steps to Visualize:

  1. Use a Scatter Chart.

  2. Set:

    • X-axis: Temperature (C)

    • Y-axis: Pressure (millibars)

Q10: Which weather type corresponds to highest humidity?

🔹 Steps to Visualize:

  1. Use a Bar Chart.

  2. Set:

    • X-axis: AVERAGE of Humidity 

    • Y-axis: Summary

Q11: What is the average comfort index by day?

🔹 Add DAX Column: Go to modelling, click new column( Already Created this one in initial stage)

Dax: 
ComfortIndex = 100 - ('WeatherData'[Humidity] * 100) - ('WeatherData'[Wind Speed (km/h)] * 0.5)

🔹 Steps:

  1. Use Bar Chart.

  2. X-axis: DayOfWeek

  3. Y-axis: AVERAGE of ComfortIndex


Q12: Forecast future temperature trend (next 7 days)

🔹 Steps:

  1. Create a Line Chart.

  2. X-axis: Date

  3. Y-axis: AVERAGE of Temperature (C)

  4. Go to Analytics Pane → Add Forecast:

    • Forecast Length: 7

    • Confidence interval: 95%

Q13: Which month shows highest average wind speed?

🔹 Add DAX Column:

Dax: 
MonthName = FORMAT('WeatherData'[Date], "MMMM")

🔹 Steps:

  1. Use a Column Chart.

  2. X-axis: MonthName

  3. Y-axis: AVERAGE of Wind Speed (km/h)

Q14: Compare actual vs apparent temperature by month

🔹 Steps:

  1. Use a Clustered Column Chart.

  2. X-axis: MonthName

  3. Y-axis: AVERAGE of both Temperature (C) and Apparent Temperature (C)

  4. Use Legend to differentiate both series.


Q15: How does temperature behave with changes in cloud cover and humidity?

🔹 Steps:

  1. Use a Bubble Chart:

    • X-axis: Cloud Cover

    • Y-axis: Temperature (C)

    • Size: Humidity

    • Legend: Optional (Summary)



टिप्पणी पोस्ट करा

0 टिप्पण्या