DAX Flashcards

1
Q

What does DAX stand for?

A

Data Analysis Expressions

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

What is DAX?

A

A library of:
- Functions
- Operators
- Constants

that can be used in formulas

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

Where is DAX used?

A
  1. SSAS
  2. Power Pivot in Excel
  3. Power BI
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Commonly used operators in DAX

A
  • ()
  • +
  • -
  • *
  • =
  • <>
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How do you indicate the AND operator in a DAX expression?

A

??

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

How do you indicate the OR operator in a DAX expression?

A

||

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

How do you concatenate two values into one string?

A

+

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

VAR syntax example

A
VAR VarName1=DAX Formula
VAR VarName2=DAX Formula

Return
Divide(VarName1, VarName2)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

VAR Example

A

VAR SalesAmount =
SUMX(Sales,
Sales [Unit Price] * Sales[Quantity])

VAR CustomerCount =
DISTINCTCOUNT (Sales[CustomerKey])

RETURN
DIVIDE (SalesAmount, CustomerCount)

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

When should you use VAR?

A

Anytime you write a complex expression. This enhances formula readability.

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

What are the benefits of using a VAR in a DAX formula?

A
  • Easier to read
  • Easier to debug
  • Re-use formulas
  • Avoid running formulas multiple times.
  • To avoid extra columns in your column list that are intermediate calculations that will not be used independently
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What special characters do you use to comment DAX code?

A

For a single line
//

For a multi-line comment
/* … */

Just writing a really long sentence so it will left justify

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

What is a calculated column?

A
  • A new column added to an existing table
  • Almost always applied row by row
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Calculated Column Syntax

A
CalculatedColumnName=
'TableName'[ColumnName1] OPERATOR 'TableName'[ColumnName2] 

Example
Total Sales =
‘Sales’[Quantity] * ‘Sales’[Unit Price]

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

How does ADDCOLUMNS work?

A
  • Automatically includes all columns from the table indicated in the Table argument
  • Adds additional columns to that table by giving a column name as text and then the field name or an expression.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

When is a calculated column processed?

A

The calculation takes place during refresh time and the result is saved in memory.

17
Q

What do aggregate functions do?

A

Facilitate data aggregation across any business dimension. Examples are:
- Time
- Geography
- Product Categories
- Total Revenue

Functions such as
- Addition
- Subtraction

18
Q

ADDCOLUMNS syntax

A

ADDCOLUMNS(Table,
name1, expression1,
name2, expression2, …)

Just writing a long sentence to left justify

19
Q

ADDCOLUMNS example

A

Yearly_Sales_By_Color =
ADDCOLUMNS(
Sales,
“ProductColor”, RELATED(Products[Color]),
“Year”, RELATED(‘Date’[Year])
)