3C. Design a semantic model in Power BI Flashcards

1
Q

What should the overarching goal be when designing a semantic model?

A

Providing set rules for what makes a good semantic model is difficult because all data is different, and the usage of that data varies. Generally, a smaller semantic model is better because it performs faster and will be simpler to use. However, defining what a smaller semantic model entails is equally as problematic because it’s a heuristic and subjective concept.

To summarize, you should aim for simplicity when designing your semantic models.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are primary and foreign keys, and what role(s) do they play in semantic models?

A

Relationships are defined between tables through primary and foreign keys. Primary keys are column(s) that identify each unique, non-null data row. For instance, if you have a Customers table, you could have an index that identifies each unique customer. The first row has an ID of 1, the second row an ID of 2, and so on. Each row is assigned a unique value, which can be referred to by this simple value: the primary key. This process becomes important when you are referencing rows in a different table, which is what foreign keys do. Relationships between tables are formed when you have primary and foreign keys in common between different tables.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a star schema?

A

In a star schema, each table within your semantic model is defined as a dimension or a fact table, as shown in the following visual. Fact at the center, dimensions as the points of the star.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are fact tables?

A

They contain observational or event data values: sales orders, product counts, prices, transactional dates and times, and quantities. Fact tables can contain several repeated values. For example, one product can appear multiple times in multiple rows, for different customers on different dates. These values can be aggregated to create visuals. For instance, a visual of the total sales orders is an aggregation of all sales orders in the fact table.

With fact tables, it is common to see columns that are filled with numbers and dates. The numbers can be units of measurement, such as sale amount, or they can be keys, such as a customer ID. The dates represent time that is being recorded, like order date or shipped date.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What are dimension tables?

A

They contain the details about the data in fact tables: products, locations, employees, and order types. These tables are connected to the fact table through key columns. Dimension tables are used to filter and group the data in fact tables. The fact tables, on the other hand, contain the measurable data, such as sales and revenue, and each row represents a unique combination of values from the dimension tables. For the total sales orders visual, you could group the data so that you see total sales orders by product, in which product is data in the dimension table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What are some typical differences between fact and dimension tables?

A

Fact tables are much larger than dimension tables because numerous events occur in fact tables, such as individual sales. Dimension tables are typically smaller because you are limited to the number of items that you can filter and group on. For instance, a year contains only so many months, and the United States are composed of only a certain number of states.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are some attributes of a simple table structure (semantic model)?

A

A simple table structure will:
- Be simple to navigate because of column and table properties that are specific and user-friendly.
- Have merged or appended tables to simplify the tables within your data structure.
- Have good-quality relationships between tables that make sense.
- If warranted, group columns into folders

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How many relationships can you have between two tables?

A

One active
Several inactive

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What are ways to build a common date table, and what step is important regardless of how you create the date table?

A
  • Source data
  • DAX
  • Power Query

And, remember to mark it as the official date table.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How do you build a date table by using source data?

A

Occasionally, source databases and data warehouses already have their own date tables. If the administrator who designed the database did a thorough job, these tables can be used to perform the following tasks:

Identify company holidays

Separate calendar and fiscal year

Identify weekends versus weekdays

Source data tables are mature and ready for immediate use. If you have a table as such, bring it into your semantic model and don’t use any other methods that are outlined in this section. We recommend that you use a source date table because it is likely shared with other tools that you might be using in addition to Power BI.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How do you build a date table by using DAX?

A

You can use the Data Analysis Expression (DAX) functions CALENDARAUTO() or CALENDAR() to build your common date table.

In Power BI Desktop, go to the Table tab on the ribbon. Select New Table, and then enter in the DAX formula. Remember to add columns for only year, month number, week of year, and perhaps week day.

The CALENDAR() function returns a contiguous range of dates based on a start and end date that are entered as arguments in the function.

Alternatively, the CALENDARAUTO() function returns a contiguous, complete range of dates that are automatically determined from your semantic model. The starting date is chosen as the earliest date that exists in your semantic model, and the ending date is the latest date that exists in your semantic model plus data that has been populated to the fiscal month that you can choose to include as an argument in the CALENDARAUTO() function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How do you build a date table by using Power Query?

A

You can use M-language, the development language that is used to build queries in Power Query, to define a common date table.

Select Transform Data in Power BI Desktop, which will direct you to Power Query. In the blank space of the left Queries pane, right-click to open the following drop-down menu, where you will select New Query > Blank Query.

In the resulting New Query view, enter the following M-formula to build a calendar table:
List.Dates(#date(2011,05,31), 365*10, #duration(1,0,0,0))

After you have realized success in the process, you notice that you have a list of dates instead of a table of dates. To correct this error, go to the Transform tab on the ribbon and select Convert > To Table. As the name suggests, this feature will convert your list into a table.

Next, you want to add columns to your new table to see dates in terms of year, month, week, and day so that you can build a hierarchy in your visual.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Why do you need to mark your date table as the date table?

A

By marking your table as a date table, Power BI performs validations to ensure that the data contains zero null values, is unique, and contains continuous date values over a period. You can also choose specific columns in your table to mark as the date, which can be useful when you have many columns within your table. Right-click the table, select Mark as date table, and then select Date table settings. The following window will appear, where you can choose which column should be marked as Date.

Remember: selecting Mark as date table will remove autogenerated hierarchies from the Date field in the table that you marked as a date table. For other date fields, the auto hierarchy will still be present until you establish a relationship between that field and the date table or until you turn off the Auto Date/Time feature. You can manually add a hierarchy to your common date table by right-clicking the year, month, week, or day columns in the Fields pane and then selecting New hierarchy. This process is further discussed later in this module.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How do you set up a table so that you can drill down in visuals?

A

Create hiearchies

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What does it mean to “flatten” a hierarchy?

A

The process of viewing multiple child levels based on a top-level parent. For example, seeing all subordinates to a manager, specifically the separate and multiple subordinate levels under a CEO, for example.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

How can you flatten a hierarchy? (For example showing all staffing levels, if the original dataset only includes two column, one with employee number, and the other column with the employee number of their manager)

A

Use PATH to create a new column showing each employee’s full parent path. Then use PATHITEM to create new columns based off the PATH column, one column for each level in the hierarchy. Then create a hierarchy of those new columns.

17
Q

What is a “role-playing” dimension?

A

When you build a visual in which one dimension table references two or more fact tables, that dimension table would act as a role playing dimension.

18
Q

What is data granularity?

A

How fine-grained is your data? Only by year, not very granular. By second, very granular.

19
Q

How should you think about granularity when building a semantic model, and why?

A

Use the least granular data possible given constraints/requirements/questions, because this will make the dataset smaller, and will make the report load faster and perform better.

20
Q

What has to be true in terms of granularity when creating relationships between tables?

A

Keys have to have the same granularity

21
Q

What types of relationships can exist between tables?

A
  • Many-to-one (*:1) or one-to-many (1: *) relationship
  • One-to-one (1:1) relationship
  • Many-to-many (.) relationship
22
Q

Describe many-to-one (*:1) or one-to-many (1: *) relationships.

A
  • Describes a relationship in which you have many instances of a value in one column that are related to only one unique corresponding instance in another column.
  • Describes the directionality between fact and dimension tables.
  • Is the most common type of directionality and is the Power BI default when you are automatically creating relationships.
23
Q

Describe a one-to-one (1:1) relationship.

A
  • Describes a relationship in which only one instance of a value is common between two tables.
  • Requires unique values in both tables.
  • Is not recommended because this relationship stores redundant information and suggests that the model is not designed correctly. It is better practice to combine the tables.
  • If you keep a one-to-one relationship in your model, the only direction available is bi-direcitonal
24
Q

Describe many-to-many (.) relationships.

A
  • Describes a relationship where many values are in common between two tables.
  • Does not require unique values in either table in a relationship.
  • Is not recommended; a lack of unique values introduces ambiguity and your users might not know which column of values is referring to what.
25
Q

What filter directions can relationships between tables have?

A
  • single cross-filter direction
  • both cross-filter directions or bi-directional cross-filtering
26
Q

Describe single cross-filter directions.

A
  • Only one table in a relationship can be used to filter the data. For instance, Table 1 can be filtered by Table 2, but Table 2 cannot be filtered by Table 1.
  • For a one-to-many or many-to-one relationship, the cross-filter direction will be from the “one” side, meaning that the filtering will occur in the table that has many values.
27
Q

Describe both cross-filter directions or bi-directional cross-filtering.

A
  • One table in a relationship can be used to filter the other. For instance, a dimension table can be filtered through the fact table, and the fact tables can be filtered through the dimension table.
  • One table in a relationship can be used to filter the other. For instance, a dimension table can be filtered through the fact table, and the fact tables can be filtered through the dimension table.
28
Q

Why should you be cautious about using bi-directional cross-filtering?

A

You should not enable bi-directional cross-filtering relationships unless you fully understand the ramifications of doing so. Enabling it can lead to ambiguity, over-sampling, unexpected results, and potential performance degradation.

29
Q

Describe the ambiguity that comes with many-to-many relationships and/or bi-directional filtering.

A

For many-to-many relationships, you can choose to filter in a single direction or in both directions by using bi-directional cross-filtering. The ambiguity that is associated with bi-directional cross-filtering is amplified in a many-to-many relationship because multiple paths will exist between different tables. If you create a measure, calculation, or filter, unintended consequences can occur where your data is being filtered and, depending on which relationship that the Power BI engine chooses when applying the filter, the final result might be different. This situation is also true for bi-directional relationships and why you should be cautious when using them.

For this reason, many-to-many relationships and/or bi-directional relationships are complicated. Unless you are certain what your data looks like when aggregated, these types of open-ended relationships with multiple filtering directions can introduce multiple paths through the data.

30
Q

What is a situation in which a many-to-many relationship might be warranted?

A

Consider the scenario where you are tasked with building a visual that examines budgets for customers and accounts. You can have multiple customers on the same account and multiple accounts with the same customer, so you know that you need to create a many-to-many relationship.

(the training says this, but I’m unsure. Can’t you use a one-to-many bi-directional? does it have to be many-to-many?)

31
Q

What are “relationship” dependencies?

A

You build a visual based on one fact table and two dimension tables. If you filter by one dimension table, this will change the sums shown from the fact table, which might change the dimensions displayed from the other dimension table. This way, two dimension tables can have dependencies, even if both point in a single direction towards a common fact table.

32
Q

What type of relationship dependency should you avoid?

A

Circular. This web of relationships is difficult to manage and becomes a daunting task to build visuals because it is no longer clear what relationships exist.