0% found this document useful (0 votes)
238 views

An Introduction To Data Models in Power BI (Slides)

Uploaded by

jejeybob
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
238 views

An Introduction To Data Models in Power BI (Slides)

Uploaded by

jejeybob
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

Data models in Power BI

An introduction to data models in Power BI


Please do not copy without permission. © ExploreAI 2023.
Data models in Power BI

What is a data model?

| A data model is a conceptual representation of data and its structure within a database.

Data models in SQL and in Power BI serve different purposes but are closely related when it comes to business
intelligence and data analysis.

_SQL_ _Power BI_

Data models, such as entity-relationship data models, are Data models help us build analytical models that enhance
primarily used for database management and data our analytical capabilities by providing relationships
storage. between data tables.

They define how data are structured, stored, and This enables us to aggregate and filter across and analyse
organised within relational database systems. from multiple sources.
2
Data models in Power BI

SQL and Power BI data models

| Since SQL and Power BI data models are related, we can apply our knowledge of data models in
SQL to Power BI, and also use them together.

_Data integration_ _Data extraction and_ _Enhanced analysis and_


_transformation_ _reporting_
● Power BI can retrieve data
from SQL databases and other ● SQL data models play a critical ● The relationships defined in
sources, such as spreadsheets role in providing structured the data model allow for
and cloud services. data in Power BI. powerful cross-filtering and
data exploration.
● These various data sources ● We can use Power BI’s Power
can be integrated into a single Query Editor to transform data ● We can also create calculated
coherent data model. from other sources, as we columns and measures in
would’ve done in SQL. Power BI, which performs
calculations similar to SQL
queries.
3
Data models in Power BI

Characteristics of a (good) data model

|
A good data model in Power BI is essential for ensuring that our reports and dashboards provide
valuable insights and are efficient to work with. Some of the key characteristics of a good data model
include:

Users should be able to quickly navigate through data, filter, and drill down to
Efficient data
gain insights without experiencing significant delays or performance issues.
exploration This requires optimising the model for responsiveness.

Aggregations are used to summarise and pre-calculate data for improved


Simplified
performance, especially when dealing with large datasets. A good data model
aggregations
should make it simple to create and manage these aggregations.

Accuracy is paramount in any data model. It should reflect the true state of the
Data
underlying data, and transformations and calculations should be carried out
accuracy accurately. Inaccuracies can lead to incorrect insights and decisions.

4
Data models in Power BI

Characteristics of a (good) data model


A good data model should be modular and designed for reuse. Well-named
Maintainability,
tables, columns, and measures, along with clear relationships and
reusability calculations, contribute to maintainability and reusability.

Performance is crucial for a responsive and user-friendly experience. A


Performance
well-designed data model should optimise queries and calculations to
optimisation
minimise load times and maximise interactivity.

Business requirements change over time. A good data model should be flexible
Flexibility enough to adapt to evolving needs. This might involve modifying relationships
or adding new data sources, while maintaining data integrity.

It’s important to note that not all “good” data models will always fit our requirements, i.e. it isn’t always
one-size-fits-all. Therefore, it’s important to know the characteristics of a good data model because, chances are,
we’ll have to experiment until we find the right balance.

5
Data models in Power BI

The star schema in Power BI

| As in SQL, a variety of data models can be implemented in Power BI. However, the most
commonly used data modelling approach in Power BI is the star schema.

A star schema is a specific type of data modelling Dimension


table
approach commonly used in Power BI and other data
warehouse and business intelligence systems. It is
characterised by a _central fact table_ connected to
multiple _dimension tables_, forming a star-like
Dimension Dimension
structure when visualised graphically. table table
Fact table

The star schema is popular because it’s simple,


optimised for query performance, scalable, easy to
maintain, and consistent. In other words, it ticks all of
the boxes of being a “good” data model.
Dimension Dimension
table table

6
Data models in Power BI

The star schema in Power BI


Let’s consider an example dataset on gender inequality:
Dimension table

Country

Dimension table
Country_ID (PK)
Fact table
Indicator
Country_name
Gender_inequality
Indicator_ID (PK)
Region
Country_ID (FK)
Indicator_description
Development
Year
Indicator_group
Indicator_ID (FK) Each row in the fact table represents a
specific event or transaction, and it
Indicator_value
includes foreign keys that link to
dimension tables.
A single table at the centre of the schema
that contains quantitative measures or
facts, such as Indicator_value.

7
Data models in Power BI

The star schema in Power BI


While we can have only one fact table in a star schema, we
can have many dimension tables. Dimension table

Country

Dimension table
Country_ID (PK)
Fact table
Indicator
Country_name
Gender_inequality
Indicator_ID (PK)
Region
Country_ID (FK)
Indicator_description
Development
Year
Indicator_group
Indicator_ID (FK)

Indicator_value
Often contains attributes and
Generally, they help answer hierarchies related to its
questions like “who”, “what”, dimension, for example,
“where”, “when”, and “how” Provides the context and Country_name and Region.
regarding the measures in the descriptive attributes for
fact table. the data in the fact table.

8
Data models in Power BI

The star schema in Power BI


Relationships are established between the fact table and
dimension tables using primary and foreign keys, enabling us Dimension table
to slice, filter, and drill down into the data effectively.
Country

Dimension table
Country_ID (PK)
Fact table
Indicator
Country_name
Gender_inequality
Indicator_ID (PK)
Region
Country_ID (FK)
Indicator_description
Development
Year
Indicator_group
Indicator_ID (FK)

Indicator_value
Each row in the fact table represents a
specific combination of measures or facts,
for example, Country, Year, and
Indicator_ID, which implies that multiple
indicator values can be associated with a
single country.
9
Data models in Power BI

How should we structure tables?

| A good and simple table structure allows us to organise the tables in the data model in a way
that makes it easy to navigate, work with, and create meaningful reports and visualisations.

Specific and accessible column and table properties

Each table should have a clear and specific purpose, Tables should have well-defined and appropriately named
representing a distinct entity or dimensions. For example, columns. Column names should be descriptive and
having distinct dimension tables such as Indicator and unambiguous, such as Indicator_description and
Country. Country_name.

Meaningful descriptions and annotations on tables and


columns can also help with accessibility. This metadata
helps us understand the purpose and content of each table
and column, especially when collaborating on a report or
dashboard.

10
Data models in Power BI

How should we structure tables?


Merge and/or append tables to simplify Good-quality relationships between tables

In some cases, data from multiple sources will have to be Establishing appropriate relationships between tables is
merged (combined) or appended (stacked) to tables in crucial for data analysis. They define how tables are
the data model in order to reduce complexity and connected and how data can be combined and analysed
redundancy. across different dimensions.

We can merge tables when we want to combine related


data from different tables into a single table. For example, Maintain referential integrity by avoiding orphaned
having Year as a column in the Gender_inequality fact records and ensuring that related data remain consistent.
table rather than in a separate dimension table.

We can append tables when we want to stack similar data Appropriate relationships include using unique values for
structures on top of each other. For example, having the primary and foreign keys and considering the cardinality
Indicator_value for all Year instances in the fact table, (such as one-to-one and one-to-many) of relationships and
rather than having distinct tables for each year and the the directions (both or single direction) of these
related indicator values. relationships.
11
Data models in Power BI

What is data granularity?

| Data granularity refers to the level of detail or specificity at which data are recorded and stored
in a dataset or database. It defines how fine-grained or coarse-grained data observations are.

_Fine-grained data (high granularity)_ _Coarse-grained data (low granularity)_

Allows for more precise and detailed analysis. Provides a more summarised view of the data.

The data is more complex which may require more A more user-friendly data model as the number of
effort to design and maintain the data model. tables and relationships to manage is reduced.

More resource-intensive to store and process data Requires less storage and may result in faster query
which may result in slower query performance. performance.

12
Data models in Power BI

So, what’s the right granularity?

The choice of data granularity really depends on the problem


we need to solve and the data we have available.

There will always be a trade-off between the complexity of


analysis and performance. Some analyses require highly
granular data to detect subtle trends and patterns, while
others can be adequately served with summarisation.

Fine-grained data can be summarised where necessary


before being used in dashboarding or reporting to optimise
performance. However, coarse-grained data cannot be
reverted into data that can provide the same level of analysis.

13

You might also like