3F. Add calculated tables and columns to Power BI Desktop models Flashcards

1
Q

What is a calculated table?

A

You can write a Data Analysis Expressions (DAX) formula to add a calculated table to your model. The formula can duplicate or transform existing model data to produce a new table.

A calculated table formula must return a table object. The simplest formula can duplicate an existing model table.

A calculated table can’t connect to external data; you must use Power Query to accomplish that task.

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

What is a cost of calculated tables, and why?

A

They increase the model storage size and they can prolong the data refresh time. The reason is because calculated tables recalculate when they have formula dependencies to refreshed tables.

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

When are calculated tables useful?

A

Calculated tables are useful to work in scenarios when multiple relationships between two tables exist, to create a role-playing dimension without having to rely on explicit DAX calls of inactive relationships (for example when a table contains two separate columns with date, like order and ship, or start and end).

They can also be used to add a date table to your model. Date tables are required to apply special time filters known as time intelligence.

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

What is the optional argument in the CALENDARAUTO function, and how is it used?

A

The CALENDARAUTO DAX function takes a single optional argument, which is the last month number of the year, and returns a single-column table. If you don’t pass in a month number, it’s assumed to be 12 (for December). For example, at Adventure Works, their financial year ends on June 30 of each year, so the value 6 (for June) is passed in.

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

How is the timespan in a date table decided by CALENDARAUTO?

A

The function scans all date and date/time columns in your model to determine the earliest and latest stored date values. It then produces a complete set of dates that span all dates in your model, ensuring that full years of dates are loaded. For example, if the earliest date that is stored in your model is October 15, 2021, then the first date that is returned by the CALENDARAUTO function would be July 1, 2021. If the latest date that is stored in the model is June 15, 2022, then the last date that is returned by the CALENDARAUTO function would be June 30, 2022.

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

What must be true for a table to be eligible for being marked as a date table?

A
  • The table must include a column of data type Date.
  • The column must contain complete years.
  • The column must not have missing dates.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is duplicated when create a calculated duplicate table?

A

A calculated table only duplicates data; it doesn’t duplicate any model properties or objects like column visibility or hierarchies. You’ll need to set them up for the new table, if required.

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

What is a calculated column?

A

You can write a DAX formula to add a calculated column to any table in your model. A calculated column formula must return a scalar or single value.

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

What is a cost of calculated columns, and why?

A

Calculated columns in import models have a cost: They increase the model storage size and they can prolong the data refresh time. The reason is because calculated columns recalculate when they have formula dependencies to refreshed tables.

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

What is a typical example of calculated columns?

A

Creating year, month, fiscal, etc, columns from a date column.

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

What is row context in the context of calculated columns?

A

The formula for a calculated column is evaluated for each table row. Furthermore, it’s evaluated within row context, which means the current row. When the formula is evaluated for each row, the ‘Due Date’[Due Date] column reference returns the column value for that row. You’ll find that Microsoft Excel has the same concept for working with formulas in Excel tables.

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

Row context does not extend beyond the current table, so how can formulas reference columns in other tables?

A

You have two options:

  • If the tables are related, directly or indirectly, you can use the RELATED or RELATEDTABLE DAX function. The RELATED function retrieves the value at the one-side of the relationship, while the RELATEDTABLE retrieves values on the many-side. The RELATEDTABLE function returns a table object.
  • When the tables aren’t related, you can use the LOOKUPVALUE DAX function.

Generally, try to use the RELATED function whenever possible. It will usually perform better than the LOOKUPVALUE function due to the ways that relationship and column data is stored and indexed.

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

What are the three ways of adding columns to a model table?

A
  • Add columns to a view or table (as a persisted column), and then source them in Power Query. This option only makes sense when your data source is a relational database and if you have the skills and permissions to do so. However, it’s a good option because it supports ease of maintenance and allows reuse of the column logic in other models or reports.
  • Add custom columns (using M) to Power Query queries.
  • Add calculated columns (using DAX) to model tables.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is the preferred way of adding columns?

A

The preference is to add custom columns in Power Query, whenever possible, because they load to the model in a more compact and optimal way.

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

When is it recommended to add columns by adding a calculated column with DAX (instead of as a custom column in Power Query)?

A
  • When you need to add a column to a calculated table
  • When the calculated column formula depends on summarized model data.
  • When the calculated column formula needs to use specialized modeling functions that are only available in DAX, such as the RELATED and RELATEDTABLE functions. Specialized functions can also include the DAX parent and child hierarchies, which are designed to naturalize a recursive relationship into columns, for example, in an employee table where each row stores a reference to the row of the manager (who is also an employee).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Adding a column using DAX is called a calculated column. What is the corresponding term for custom columns added in Power Query added using M?

A

Computed columns

17
Q

What does the RELATED function do?

A

The RELATED function retrieves the value at the one-side of the relationship.

18
Q

What does the RELATEDTABLE function do?

A

The RELATEDTABLE retrieves values on the many-side. The RELATEDTABLE function returns a table object.

19
Q

What is another phrase for flattening hierarchies?

A

Naturalizing a recursive relationship into columns, for example, in an employee table where each row stores a reference to the row of the manager (who is also an employee).