DAX - Statistical Functions Flashcards

1
Q

What do statistical functions do?

A
  • Calculate values related to statistical distibutions and probability
  • Calculations and comparisons that reveal meaningful information about the data. Such as:
    Trends
    Patterns
    Relationships
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Common statistical functions

A
  • Average
  • Median
  • Count
  • Distinct(Count)
  • Min
  • Max
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How does MAX work?

A

Returns the largest numeric value or largest string in a column. Ignores logical values.

NOTE: As the MAX function ignores logical values, TRUE and FALSE in the table are interpreted as texts. Texts are considered “larger” than numbers in DAX alphabetically, so the largest value in the column is TRUE, as it’s the last in alphabetical order.

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

How does MIN work?

A

Returns the smallest numeric value or shortest string in a column. Ignores logical values.

NOTE: As the MIN function also ignores logical values, same as the MAX function, the sequence of blank values, numbers and texts is followed in ascending order. A blank value in the sample column is considered as the
minimum value.

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

How does the average function work?

A
  1. It sums up all the numbers in a dataset
  2. Divides the result by the total count of numbers
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How does the median function work?

A
  1. Sorts the numbers in asc order
  2. Selects the middle number
  3. If there are two middle numbers, take the average of the two as the median.

For example, if the ItemPrice column in the Sales table contained 2 values,
the formula would be calculated as:
(160 + 180) / 2 = 170

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

Example of AVERAGEX function

A

AVERAGEX (Sales, Sales[Freight] + Sales[TaxAmt])

In this example:
1. Sales[Freight] + Sales[TaxAmt] is calculated for each row
2. Then the sums are averaged

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

How does AVERAGEX work?

A

AVERAGEX(Table, Sales[Quantity] * Sales[Price])

It goes row by row and calculates the Sales Amount (quantity x price). Then it calculates an average of Sales Amount amongst all the rows that were calculated

For example, if the ItemPrice column and the QuantitySold column each contained 8 values, the formula would be calculated as:
((120 * 5) + (140 * 7) + (180 * 3) + (130 * 6) + (200 * 4) + (240 * 9) + (160 * 2) + (190 * 8)) / 8 = 962.50

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

What does AVERAGEA do?

A

AVERAGEA([ColumnName)
Calculates the average of non blank cells in a column

NOTE
-Values that evaluate to TRUE count as 1.
-Values that evaluate to FALSE count as 0 (zero).
-Values that contain non-numeric text count as 0 (zero).
-Empty text (“”) counts as 0 (zero).

For example, if the ItemPrice_withText column contained 8 values, with non-numeric values being counted as 0, the formula would be calculated as:
(120 + 1 + 0 + 130 + 180 + 0 + 280 + 1) / 8 = 89

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

Is the Median or Average less affected by outliers and extreme values?

A

Median

It is therefore useful for datasets with skewed distributions

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

What is returned if there are no rows to count using COUNT or DISTINCTCOUNT

A

(blank)

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

What does count do?

A

Counts the total number of rows, containing any or no value

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

What does COUNTBLANK do?

A

Counts the number of blank or empty rows in a column

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

How does COUNTA work?

A

It counts the number of cells in a column that are not blank

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

How does COUNTAX work?

A

Goes row by row and and counts rows where the specified expression results in a non-blank result.

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

COUNTAX syntax

A
COUNTAX(<table>, <expression>)

Example
COUNTAX (FILTER (Reseller, [Status] = "Active"), [Phone])

In the example above, it counts the number of non-blank rows in the phone column using the table that results from filtering the reseller table on Status=Active

17
Q

What does COUNTROWS count?

A

=COUNTROWS([‘Orders’])
=COUNTROWS(RELATEDTABLE(ResellerSales))

It counts the number of rows in the specified table or a table defined by an expression

18
Q

How do MINA or MAXA work?

A
  • Gets the smallest or largest value in a column and doesn’t ignore logical values and text.
  • This could therefore be used to get the smallest or largest date. MIN and MAX only work on numbers.
19
Q

MINX syntax

A
MINX(<table>, <expression>)
20
Q

How does MINX work?

A
MINX (FILTER (Sales, [SalesTerritoryKey] = 5), [Freight])

An expression is evaluated for each table row and then the smallest value is returned.

In this example, the Sales table is filtered for SalesTerritoryKey 5. Then the function gets the MIN freight for territory 5.

21
Q

How does the MAXX function work?

A
MAXX (Sales, Sales [TaxAmt]+ Sales [Freight])

This function evaluates an expression for each row and then returns the largest value.

In the above example, the tax plus frieght is calculated for each row and then the max value is returned.

22
Q

MAXX syntax

A
MAXX(<table>, <expression>)
23
Q

Variance of a Sample Population

A
VAR.S(<column>)

Returns the variance of a column containing a sample population.

Just writing a long sentence so it will left justify

24
Q

Example Variance using sample population

A

Assuming the column on which the variance/deviation will be calculated refers to a sample population:

Example: VAR.S(Sales[ItemPrice]) = 1.629

25
Q

Standard Deviation of sample population

A

~~~
STDEV.S(<column>)
~~~</column>

Returns the standard deviation of a column containing a sample population.

26
Q

Example Standard Deviation using sample population

A

Assuming the column on which the variance/deviation will be calculated refers to a sample population:

Example: STDEV.S(Sales[ItemPrice])= 40

27
Q

Variance of Entire Population

A
VAR.P(<column>)

Returns the variance of a column, assuming that the column refers to the entire population.

28
Q

Example Variance using entire population

A

Assuming the column on which the variance/deviation will be calculated contains the entire population of data points:

Example: VAR.P(Sales[ItemPrice]) = 1.425

29
Q

Standard Deviation of entire population

A
STDEV.P(<column>)

Returns the standard deviation of a column containing an entire population.

30
Q

Example Standard Deviation using entire population

A

Assuming the column on which the variance/deviation will be calculated contains the entire population of data points:

Example: STDEV.P(Sales[ItemPrice]) = 38

31
Q

Combination Function

A

COMBIN(n,k)

Returns the number of ways k items can be selected from n, where the order DOES NOT matter.

Example: COMBIN(49,6) = 13.983.816

32
Q

Permutation Function

A

PERMUT(n,k)

Returns the number of ways k items can be selected from n, where the order DOES matter.

Example: PERMUT(49,6) = 10.068.347.520