Reports with Power BI¶
Exercise power-bi-reports-annex.pdf · PDF
You apply for your first job. The interview goes well, and then comes the sentence: "By the way, here we use Power BI." You have spent five months in Superset. Do you start from zero?
No. You know what a dashboard is for, what a KPI is, what a filter does and which chart answers which question. That knowledge is yours, not Superset's. This lesson checks that it survives a change of tool: you will rebuild three charts of your Steam market dashboard in Power BI and prove, with SQL, that they show the same numbers.
What you will learn
- Name the Power BI word for each Superset word you already use
- Find your way around Power BI Desktop: the report canvas, the Visualizations pane and the Data pane
- Build a card, a column chart and a bar chart by dragging fields into field wells
- Add a slicer and explain what it does to the other visuals on the page
- Describe what Publish does, and what kind of account and licence it needs
- Defuse two traps: the card that says 27K, and the Power BI "dashboard" that is not what you think
You met Power BI's data side in Getting data with Power BI and Power Query; today is the part people actually look at.
Same game, other console¶
Imagine your favourite game comes out on another console. The rules are the same. The map is the same. Your strategy still works. Only the buttons have other names. You do not need a new manual: you need the button chart.
Power BI is Microsoft's tool for turning data into interactive reports. It has two halves: Power BI Desktop, a free Windows application where you build, and the Power BI service, a website where you publish and share.
Here is the button chart. Keep it open for the whole lesson:
| In Superset | In Power BI | Careful |
|---|---|---|
| Dashboard | Report (one or more pages) | A Power BI "dashboard" is something else: see the last section |
| Chart | Visual | You pick it in the Visualizations pane |
| Big Number | Card | Shows 27K by default instead of 26,685 |
| Dataset (columns, metrics) | Semantic model, listed in the Data pane | Older versions call the pane Fields |
| Metric and dimension boxes | Field wells: Values, X-axis, Y-axis | You drag a field into a well |
| Native filter | Slicer | A slicer is a visual: it sits on the canvas |
| Draft → Published | Publish to the Power BI service | Needs a work or school account |
Careful: Power BI Desktop only runs on Windows
Power BI Desktop is free to download, but it needs Windows 10 or later. There is no Linux version, and your lab VM is not a Windows machine. If you have no Windows PC, you can still do the most important half of this lesson: predicting every number in SQL Lab. The building half you follow on a Windows computer.
One more warning: Microsoft releases a new version of Power BI Desktop every month, and buttons move. If a menu on your screen is not called exactly what this page says, look for the nearest name. The ideas do not move.
A tour of the screen¶
Open Power BI Desktop and look at four places. No more.
flowchart TB
RIB["<b>Ribbon</b><br>tabs with tools: Home, Insert, Modeling"]
subgraph MAIN ["Under the ribbon"]
direction LR
CAN["<b>Report canvas</b><br>the white page where<br>the visuals go"]
VIS["<b>Visualizations pane</b><br>choose the type of visual,<br>fill its field wells"]
DAT["<b>Data pane</b><br>your tables and<br>their fields"]
DAT -- "drag a field" --> VIS
VIS -- "draws the visual" --> CAN
end
RIB --> MAIN
| Place | Where | What it is for |
|---|---|---|
| Ribbon | Across the top | The tabs with the tools: Home, Insert, Modeling |
| Report canvas | The big white area in the middle | The page where you place and arrange your visuals |
| Visualizations pane | On the right | Choose the type of visual, then fill its field wells |
| Data pane | On the right | The tables and fields of your data, ready to drag |
Now look for the SQL editor. There is none in sight. This is the biggest difference of the day: in Superset you could always open SQL Lab and write the query yourself. In Power BI you drag fields, and the query is written for you.
No SQL does not mean no query
Every visual still asks the data a question: count these rows, group them by that column. Power BI just writes it behind the curtain. Which means you cannot read it to check it. So you check it the other way round: you compute the answer yourself in SQL first, and then see whether the visual agrees.
Visuals and field wells¶
A visual is one chart, table or number on the report canvas. A field well is a labelled box in the Visualizations pane where you drop a field to tell the visual what to draw.
A field is simply a column of your data, such as price_band or release_year. Each type of visual has its own wells, and they map directly onto what you already do in Superset:
| Visual | Field wells you fill | What you did in Superset |
|---|---|---|
| Card | Values | Big Number: one metric |
| Clustered column chart | X-axis, Y-axis | Bar chart with vertical bars: a dimension and a metric |
| Clustered bar chart | Y-axis, X-axis | Bar chart with horizontal bars: the same two, swapped |
| Slicer | Field | Native filter: the column to filter by |
When you drop a field into a well that expects a number, Power BI must decide how to summarise it: add it up, count it, average it. It guesses. And it often guesses Sum.
Careful: Sum is not Count
Drag number (the game's row number) into a card and Power BI adds the numbers up: a figure in the tens of millions that means nothing. You wanted to know how many games there are, not the total of their labels. Open the small arrow next to the field in the well and choose Count. Always ask what the number in front of you is a sum, a count or an average of.
Pages and slicers¶
A Superset dashboard is one screen, sometimes split into tabs. A Power BI report is made of pages: one or more canvases, like slides, each with its own visuals. The page tabs sit along the bottom of the canvas. One page for the overview, another for the detail.
A slicer is a filter that lives on the canvas as a visual. The reader clicks a value, and the other visuals on the page keep only the rows that match.
It is the same idea as the native filter you built in Filters and cross-filters: one control, many charts react, and behind every one of them a WHERE has been added. Two details are different:
| Superset native filter | Power BI slicer | |
|---|---|---|
| Where it lives | In the filter bar, outside the charts | On the canvas, among the visuals |
| What it touches by default | The charts in its scope | Every other visual on its page |
| How you exclude a chart | Change the filter's scoping | Select the slicer, then Format → Edit interactions, and set that visual to None |
Try it: predict, build, compare¶
The method matters more than the clicks: first you predict in SQL, then you build, then you compare. A visual you cannot check is a visual you cannot trust.
Power BI will read a file, so you need games_clean.csv: your cleaned Steam table from Unit 2, exported to a file. If you do not have it yet, make it yourself in two minutes.
Make games_clean.csv yourself
In SQL Lab, set the LIMIT dropdown to 100 000. The default, 1 000, would give you a file with only 1,000 games. Run SELECT * FROM games_clean and press Download to CSV.
The screen only displays the first 10,000 rows and says so in a notice. The file has all of them: check that it holds 26,685 rows of data. The original, uncleaned file is on the Resources page, but it is not the one you want here.
Step 1 — Predict. In SQL Lab, with the database Dades classe, run these three queries one at a time (SQL Lab only shows the result of the last statement) and write the results down:
SELECT COUNT(*) AS games FROM games_clean;
SELECT release_year, COUNT(*) AS games FROM games_clean
GROUP BY release_year ORDER BY games DESC LIMIT 1;
SELECT price_band, COUNT(*) AS games FROM games_clean
GROUP BY price_band ORDER BY games DESC;
Then run the same three again with WHERE owners_tier = 'Hit' before the GROUP BY. That is what the slicer will do in Step 4. A hit is a game with at least a million owners. You should end up with these six results:
| Question | All games | Only owners_tier = 'Hit' |
|---|---|---|
| Number of games | 26,685 | 623 |
| Year with most games | 2018, with 8,845 | 2015, with 80 |
| Price band with most games | Under 5, with 11,613 |
Free, with 182 |
Step 2 — Load the file and build the card.
| Do this | You should see |
|---|---|
Home → Get data → Text/CSV, choose games_clean.csv, check the preview, Load |
The table and its fields appear in the Data pane |
In the Visualizations pane choose Card. Drag number from the Data pane into the Values well |
A card with a huge number: it is a sum |
| Open the small arrow next to the field in the well and choose Count | The card says 27K |
| Format visual → Visual → Callout values → Values → Display units: None | The card says 26,685, digit by digit like your first query |
Step 3 — Two charts. Click an empty part of the canvas first, or the new visual will replace the card instead of being added next to it.
| Do this | You should see |
|---|---|
Clustered column chart: release_year in X-axis, number in Y-axis, set to Count |
Games released per year. The tallest column is 2018 |
Clustered bar chart: price_band in Y-axis, number in X-axis, set to Count |
Games per price band. The longest bar is Under 5 |
| For each visual: Format visual → General → Title, and write what it shows | Two titles a stranger could understand |
Step 4 — The slicer.
| Do this | You should see |
|---|---|
Click an empty part of the canvas. Choose Slicer and drag owners_tier into its Field well |
A list with Hit, Mid and Niche on the canvas |
| Click Hit | All three visuals change: the card reads 623, the tallest column is 2015, the longest bar is Free |
Compare with your "hits only" predictions. If all six numbers match, you have not just built a report: you have verified one.
Careful: 27K is not a mistake
Your SQL says 26,685 and the card says 27K. Who is right? Both. The card rounds to thousands for display; the value behind it is still 26,685. Setting Display units to None shows every digit. You saw the same thing in Superset, where a Big Number said 26.7k until you changed its number format. A rounded number is fine on a poster and wrong on an invoice: decide which one your reader needs.
If something goes wrong
| What you see | What happened | Fix |
|---|---|---|
| The card shows a number in the millions | The field is on Sum | Open the arrow next to the field in the well and choose Count |
The year axis shows 2,004 with a comma, or there is one single bar |
release_year is being added up as if it were a quantity |
Put it in X-axis and choose Don't summarize for it |
| A column with no year at the left of the chart | One game in the table has no release date | Nothing: it is real. Good eye |
| The card disappeared when you added the chart | The card was still selected, so the new visual replaced it | Undo, click an empty part of the canvas, then choose the new visual |
Publishing to the service¶
In Superset, your dashboard lived on the server from the first click. Here, everything you have built so far lives in one file on your PC: File → Save creates a .pbix file. Nobody else can see it.
To change that you publish:
| Do this | What happens |
|---|---|
| Home → Publish | Power BI asks you to sign in |
| Sign in with a work or school account | Personal addresses such as Gmail are refused |
| Choose My workspace, then Select | The file travels to Microsoft's cloud |
| Open the link Power BI answers with | Your report, in the browser |
What travelled to the cloud: the report, the data, or both? Both. The report goes up together with its semantic model, and the model carries a copy of the data inside. This is called importing: the 26,685 rows are no longer only in your CSV file, they are also inside the published report.
flowchart LR
subgraph SUP ["<b>Superset</b>"]
direction LR
DB1[("PostgreSQL<br>the data stay here")] -- "query on every view" --> D1["Dashboard<br>on the server"]
end
subgraph PBI ["<b>Power BI</b>"]
direction LR
F["<b>.pbix file</b> on your PC<br>report + a copy of the data"] -- "Publish" --> S["<b>Power BI service</b><br>My workspace"]
end
Careful: publishing is not sharing
Sounds familiar? After Publish, your report sits in My workspace, and only you see it. A free licence is enough for that. Sharing it with other people is a separate step, and it needs a paid licence. In Publishing and permissions you learnt that Published did not mean "everyone can see it". The same lesson, on the other console.
Two tools, two answers to the same question: how does my chart reach other people? In Superset you gave a role access to a dataset. In Power BI you publish to a workspace and then share. The question is the same on every console.
The word that changes meaning¶
One button on the chart has the same name on both consoles and does something different.
What you built in Superset — a screen of charts you can filter — matches a Power BI report. In Power BI, a dashboard is another thing: a single page of tiles that you pin from reports, to keep the highlights in one place.
| Power BI report | Power BI dashboard | |
|---|---|---|
| Pages | One or more | Exactly one |
| Made of | Visuals | Tiles pinned from reports |
| Can you filter or slice it? | Yes | No |
| Where it exists | Power BI Desktop and the service | Only in the service |
So if a colleague says "send me the Power BI dashboard", ask one more question. They may well mean the report.
Key takeaways¶
- Power BI has two halves: Power BI Desktop (free, Windows only) to build, and the Power BI service (a website) to publish and share.
- The ideas are the ones you know; the names change. Dashboard → report, chart → visual, Big Number → card, native filter → slicer, dataset → semantic model.
- You build by dragging a field into a field well. There is no SQL editor: Power BI writes the query, so check Sum against Count.
- A slicer is a filter that sits on the canvas and filters the other visuals on its page.
- Predict in SQL, build, compare.
games_cleanhas 26,685 games; a card that says 27K is rounding, not lying. - Publish sends the report and a copy of the data to My workspace, where only you see it. Sharing is a separate step that needs a paid licence.
- A Power BI dashboard is a single page of pinned tiles in the service. Your Superset dashboard matches a Power BI report.
Quick check¶
1. What is the Power BI name for what Superset calls a native filter?
- Card
- Slicer
- Field well
- Tile
A slicer filters the other visuals on its page, like a native filter does for the charts in its scope. The difference is where it lives: a slicer is itself a visual, placed on the canvas. A card is the Big Number.
2. You drag number into a card and it shows a figure in the tens of millions. What happened?
- The CSV file was loaded several times
- Power BI is rounding the number of games
- The field is being summed instead of counted
- The slicer is set to Hit
Power BI guessed Sum and added up the row numbers of all the games: a total that means nothing. Open the arrow next to the field in the field well and choose Count to get how many games there are.
3. Your SQL query returns 26,685 games and your Power BI card says 27K. Who is right?
- SQL: Power BI lost some rows while loading the file
- Power BI: it counts the row with no release date twice
- Both: the card rounds to thousands for display, and Display units: None shows 26,685
- Neither: the two tools cannot be compared
The value behind the card is 26,685; only its display is rounded. Changing Display units to None shows every digit. This is why you predict in SQL first: you knew which number to expect.
4. You press Publish and choose My workspace. Pick the two statements that are true.
- The report and a copy of the data travel to the Power BI service
- Your whole class can now open the report
- Only you can see it there, until you share it with a paid licence
- The data stay only on your PC and the report queries them live
Publishing uploads the report with its semantic model, which holds an imported copy of the data. And My workspace is yours alone: publishing is not sharing. Sharing needs a paid licence.
5. Which sentence describes a Power BI dashboard?
- A report with several pages that you can slice
- The white area of Power BI Desktop where you place visuals
- A single page of tiles pinned from reports, which exists only in the service
- The file with the
.pbixextension
Same word, different button. A Power BI dashboard is one page of pinned tiles, lives only in the service and cannot be sliced. What you built in Superset matches a Power BI report. The white area is the report canvas.
6. Why should you compute the numbers in SQL before building the visuals in Power BI?
- Because Power BI cannot count rows by itself
- Because Power BI needs a SQL query to load a CSV file
- Because Power BI writes the query for you, so your own result is the only way to check it
- Because SQL results are always rounded and Power BI's are exact
There is no SQL editor in sight in Power BI: you drag fields and the query is generated. You cannot read it, so you predict, build and compare. If the two numbers disagree, something is wrong, usually Sum instead of Count.
7. Your report page has a slicer set to Hit, and the card now reads 623. Your reader wants the card to keep showing all 26,685 games while the two charts still follow the slicer. What do you do?
- Delete the slicer and write a
WHEREin the SQL editor - Publish the report: slicers do not act on cards in the service
- Select the slicer, open Format → Edit interactions and set the card to None
- Move the card to the Data pane
By default a slicer filters every other visual on its page. Edit interactions is how you take one visual out of its reach, the same idea as changing the scoping of a Superset filter. There is no SQL editor to write a WHERE in.
You now speak two consoles. So which one should you use, and, more important, what do you actually say with the charts once they are built? Next: Superset vs Power BI, and data storytelling.