DEV Community

Cover image for Let's Talk Relationships and Joins
gikonyo-v
gikonyo-v

Posted on

Let's Talk Relationships and Joins

Here's something nobody tells you when you start Power BI: the visuals are the easy part.

You can figure out a bar chart in ten minutes. But the moment your data comes from more than one table and nothing is adding up correctly, that's where most beginners quietly panic. I know I did.

Relationships and joins. Here's what they actually mean.

Why Your Tables Need to Talk to Each Other
Imagine you work at a retail shop. You have two lists:

  1. A Customers table - names, IDs, locations
  2. A Sales table - order IDs, amounts, and the customer ID for each purchase.

These two tables live separately. But when your boss asks "which customers spent the most last month?", now you need both. You can't answer that question with just one table.

That's what a relationship does in Power BI. It creates a bridge between two tables so they can work together in your reports.

The Key Concept: Primary and Foreign Keys
Every relationship needs a common column. A column that appears in both tables.
Like in our tables above
Customers table has CustomerID. This is the primary key ,unique per customer.
Sales table has CustomerID too. This is the foreign key,it references the customer.

Power BI uses this shared column to match rows across tables. When you drag CustomerName from one table and TotalSales from another into the same visual, the relationship is what makes them line up correctly.

Star Schema. The One You'll Use Most
Power BI works best with a star schema. One central table called the fact table surrounded by supporting tables called dimension tables.

Real-world example:

  • Fact table: Sales - every transaction, with amounts and IDs
  • Dimension tables: Customers, Products, Dates, Regions

The Sales table connects to all of them. From this setup you can answer:
What product sold most in Nairobi in Q1? Pulling from Products, Regions, Dates, and Sales all at once.
It looks like a star on the model view. Hence the name.

Join Types. What Gets Included?
When two tables connect, Power BI needs to know what to do when there's no match. That's where join types come in.

Inner Join - only rows that match in both tables. A customer with no sales? Gone. A sale with no matching customer? Also gone. Strictest filter.

Left Outer Join - keeps everything from the left table, matches where possible. All customers appear, even those who never bought anything. Their sales columns just show blank.

Full Outer Join - keeps everything from both tables, matches where it can. Nothing gets left out.

Real-world use: if you're building a report to find customers who haven't purchased yet, a Left Join is your answer. Inner Join would erase them entirely.

How It Changes Your Reports
Once your relationships are set correctly, Power BI does the heavy lifting. Your slicers filter across tables automatically. Your totals actually make sense. A date filter on your calendar table combs through sales, products, and regions, because the relationships connect them.

Without this? You're just making pretty charts on broken data. Again, learned it the hard way.

Get the relationships right first. Everything else follows.

What tripped you up most when you first set up relationships in Power BI? Drop it below.

Top comments (0)