Power BI

Context: FIT3003_MOC · the BI reporting layer on top of the warehouse — it presents what OLAP retrieves · lab case the W7 Book Sales star from Multi-Fact Star Schemas Parent Framework: OLAP (On-Line Analytical Processing)

Quick Revision

  • 🎯 Objective: Microsoft’s BI tool (desktop web) for loading, modelling and visualising data ➔ workflow Data [Table] Model Report, then publish to the Service portal.
  • ⚡ Key Constraint: the Model must reproduce the star (dimension 1 fact *), and every visual’s default aggregation must match the measure ➔ otherwise the chart silently answers a different question.

📝 Core

  • Data [Table] view ➔ connect, shape and transform raw data; shaping happens in the Power Query Editor (query pane · formula bar · table name & properties).

  • Model view ➔ build table relationships the data model design.

  • Report view ➔ pick a visual type (blank template), then tick or drag fields from the Data pane; numeric columns carry and are auto-aggregated (“Sum of NUM_OF_BOOKS by CATEGORYDESCRIPTION”).

  • Connectors ➔ files (CSV, text, Excel) · databases (SQL Server, Oracle, Azure) · online services (SharePoint, Dynamics 365, Salesforce, Google Analytics) · others (Web, Spark, semantic models); the list differs Desktop vs Web.

  • Desktop vs Web ➔ Desktop: one application, left pane switches Report / Table / Model / DAX Query views, full data prep and modelling. Web: report editing and semantic-model editing are separate tabs (import tables first, then switch to editing mode, top right); data prep, import and advanced modelling are more restricted. Either completes the lab.

  • DAX ➔ Data Analysis Expressions — the formula language (functions, operators, values) of Power BI, Analysis Services and Power Pivot; a DAX query must contain an EVALUATE statement (others: DEFINE, MEASURE, VAR, ORDER BY, START AT).

  • Filter scope ➔ visual level (that visual only) · page level (every visual on the page) · report level (every visual on every page).

  • Publish & portal ➔ Desktop work must be published to reach Power BI Service (Web work already lives there); the portal lists Dashboards (one auto-created per loaded workbook, same name), Reports, and Semantic Models (the connected data sources). Mobile layout re-arranges the visuals for a phone canvas.

  • Connecting to a lakehouse (W12) ➔ ① pick the tables the dashboard needs (dw.sales_fact its dimensions, Delta files on S3/ADLS) and grant the report user SELECT ② start a SQL warehouse (Databricks: SQL Warehouses ➔ Connection details ➔ copy server hostname HTTP path) — a Spark SQL endpoint returning results over ODBC ③ Power BI Desktop ➔ Get Data ➔ Azure Databricks ➔ paste hostname HTTP path, sign in (Entra ID or token), tick tables, choose Import or DirectQuery, publish ➔ Data Lakehouse.

⚖️ Core Decision Matrix

Source pathHowFreshnessCost
Oracle DW ➔ CSV export ➔ Text/CSV Importmanual exportfrozen at export time; updates only when someone re-exports and clicks Refreshnone beyond the manual step
SQL endpoint ➔ Importscheduled copy into the modelas fresh as the last scheduled refreshfast visuals
SQL endpoint ➔ DirectQueryevery visual queries the endpoint livealways currentcosts compute per interaction

When It Flips: a CSV is a copy frozen at export time; a live connection always shows the current data — DirectQuery when freshness matters more than compute spend, Import when a scheduled refresh is fresh enough.

🗂️ Schema

Book Sales semantic model — two facts sharing two dimensions:

  • · · ·
erDiagram
  STOREDIM      ||--o{ BOOKSALESFACT : StoreID
  TIMEDIM       ||--o{ BOOKSALESFACT : TimeID
  CATEGORYDIM   ||--o{ BOOKSALESFACT : CategoryID
  STARRATINGDIM ||--o{ BOOKSALESFACT : StarID
  CATEGORYDIM   ||--o{ REVIEWFACT    : CategoryID
  STARRATINGDIM ||--o{ REVIEWFACT    : StarID
  • Model view reading ➔ 1 on each dimension, * on each fact; the two facts have no relationship to each other, only through the shared CategoryDIM and StarRatingDIM.
  • Filter propagation follows the lines ➔ a slicer on a shared dimension filters both facts; StoreDIM and TimeDIM reach BookSalesFACT only, so review visuals ignore them.

📊 Applied Exercise

Problem: the five Book Sales requirements as visuals (the SQL versions are in Multi-Fact Star Schemas).

RequirementFactFieldsAggregationDeck’s visual
total sales per bookstore per monthBookSalesFACTSuburb (StoreDIM), Month (TimeDIM)Sum of TOTAL_SALEStable
books sold per categoryBookSalesFACTCategoryDescriptionSum of NUM_OF_BOOKSclustered column, Year as legend
category with the highest total salesBookSalesFACTCategoryDescription, sorted descSum of TOTAL_SALEStreemap — built with Count ⚠️
reviews per categoryReviewFACTCategoryDescriptionSum of NUM_OF_REVIEWdonut
5-star reviews per categoryReviewFACTCategoryDescription visual-level filter StarDescription ExcellentSum of NUM_OF_REVIEWcolumn / donut
  • 5 stars Excellent ➔ the case defines the scale as 5 stars for excellent down to 1 for poor; the deck’s funnel (Sum of NUM_OF_REVIEW by STARDESCRIPTION) shows Good , Excellent , Average , Not Good , Poor .

⚠️ Common Mistakes

  • 💡 Accepting the default aggregation ➔ the deck’s treemap is “Count of TOTAL_SALES” — it counts fact rows per category, not dollars; switch the field to Sum.
  • 💡 ID on the axis ➔ “Sum of NUM_OF_BOOKS by CATEGORYID” plots codes; management reads CategoryDescription from the dimension.
  • 💡 5-star filter at page level ➔ BookSalesFACT also carries StarID, so a page filter silently restricts every sales visual on the page too; scope it to the visual.

🧠 Active Recall