In this article we'll use a real-world example of data from farms in Kenya to show you how it's done. You'll learn how to take a messy file, clean it up, use some simple but powerful formulas, and create insightful charts—all using Power BI.
1. Cleaning Up Your Data
The first and most important step in Power BI is to clean and prepare your data. Power BI has a powerful tool for this called the Power Query Editor.
Getting Your Data into Power BI
We're using a simple CSV file with data about crops in Kenya. To pull data into Power BI, we simply use the "Get data" feature and select our csv file. Once it's loaded, Power Query shows you a preview of your data.
Cleaning the Dataset
Our Kenya Crops dataset has a few common problems that we need to fix:
• "Error" messages: Some cells just say "Error." We replace these cells with a blank or label it as "Unknown."
• Empty cells: Some cells in our data are just blank. We fill them with a zero, a label like "Unknown".
• Numbers that are text: We need to make sure our numbers are actually numbers.
• Missing information: We notice that some rows are missing the final profit number, even though they have the revenue and cost.
By taking the time to clean the data, we make sure our final analysis is accurate and trustworthy.
2. Using DAX (Data Analysis Expressions)
DAX (Data Analysis Expressions) in Power BI is a formula language used to create custom measures, calculated columns, and tables for advanced data analysis, manipulation, and modeling. It enables dynamic filtering, complex calculations like time intelligence (e.g., Year-over-Year), and row-level security, enhancing raw data into actionable insights.
Let's look at some common DAX functions and how they help us understand our Kenya Crops data better.
SUM and AVERAGE
• SUM(): This adds up all the numbers in a chosen column. If you want to know the total revenue from all crops, you'd use SUM() on the 'Revenue (KES)' column.
◦ Example: Total Revenue = SUM('Kenya Crops'[Revenue (KES)])
• AVERAGE(): This calculates the average of all numbers in a chosen column. To find the average amount of crop harvested (yield), you'd use AVERAGE() on the 'Yield (Kg)' column.
◦ Example: Average Yield = AVERAGE('Kenya Crops'[Yield (Kg)])
SUMX and AVERAGEX
Sometimes, you need to do a calculation for each individual row before adding or averaging them up. This is where SUMX() and AVERAGEX() are incredibly powerful.
• SUMX(Table, Expression): This function goes through each row of a specified Table, performs a calculation (Expression) for that row, and then adds up all those individual results.
◦ Example: Total Calculated Profit = SUMX('Kenya Crops', 'Kenya Crops'[Revenue (KES)] - 'Kenya Crops'[Cost of Production (KES)])
• AVERAGEX(Table, Expression): Similar to SUMX(), this goes through each row, performs a calculation, and then finds the average of those results.
◦ Example: Average Profit per Acre = AVERAGEX('Kenya Crops', ('Kenya Crops'[Revenue (KES)] - 'Kenya Crops'[Cost of Production (KES)]) / 'Kenya Crops'[Planted Area (Acres)])
CALCULATE
CALCULATE() helps you focus your calculations on specific parts of your data.
◦ Example: What was the total revenue only from 'Potatoes'?
Total Revenue Potatoes = CALCULATE(SUM('Kenya Crops'[Revenue (KES)]), 'Kenya Crops'[Crop Type] = "Potatoes")
◦ Here, CALCULATE tells Power BI to only looking at rows where the 'Crop Type' is 'Potatoes', and then SUM the 'Revenue'.
Joining Text Together: Concatenation with &
Sometimes you want to combine text from different columns. The ampersand (&) symbol lets you do this easily.
• Example: To create a clear label like "Potatoes - Organic" by combining the 'Crop Type' and 'Crop Variety' columns:
Crop Identifier = 'Kenya Crops'[Crop Type] & " - " & 'Kenya Crops'[Crop Variety]
• This makes our data easier to read and understand at a glance.
3. Making Dashboards That Tell a Story
After cleaning and calculating, we use Power BI's visualizations to turn the numbers into engaging charts and graphs that anyone can understand. These visuals are what help people make smart decisions quickly.
Cards
In Power BI, a card is a type of visual specifically designed to display a single, important data point or a small set of related summary numbers. Their purpose is to provide an immediate, at-a-glance summary of performance, cutting through the complexity of larger charts and tables
Bar and Column Charts
Bar and column charts are fantastic for comparing different things. Column charts usually compare things over time or across different groups, while bar charts are great when you have long names for your categories.
Line Charts
Line charts are perfect for showing how something changes over a period, like days, months, or years. They connect the dots to reveal patterns and trends.
Conclusion
From a jumbled spreadsheet to clear, actionable insights—that's the magic a Power BI analyst performs. By carefully cleaning data, using the powerful DAX language to create smart calculations, and then building engaging visuals, analysts transform raw numbers into compelling stories. These stories help businesses understand what's happening, why it's happening, and what they should do next. Our Kenya Crops example shows how these technical skills aren't just about numbers; they're about making a real difference in the world, helping farmers and businesses thrive.









Top comments (0)