DAX Quick Reference Guide
DAX Quick Reference Guide
For Microsoft SQL Server Analysis Services, Power Pivot in Excel, and Power BI Desktop
Returns a table with a single column named “Date” that contains a contiguous set of dates. The
range of dates is from the specified start date to the specified end date, inclusive of those two
dates.
Syntax: CALENDAR(<start_date>, <end_date>)
CALENDAR Term Definition
Returns the specified date in datetime format. In contrast to Microsoft Excel, which stores dates
as a serial number, DAX date functions always return a datetime data type.
Syntax: DATE(<year>, <month>, <day>)
Term Definition
year A number representing the year. The value of the year argument can include one to
DATE four digits. The year argument is interpreted according to the date system used by
your computer.
month If month is a number from 1 to 12, it represents a month of the year. 1 represents
January, 2 represents February, and so on until 12 that represents December.
day A number representing the day or a calculation. If day is a number from 1 to the
last day of the given month then it represents a day of the month.
Description: Returns a number from 1 to 7 identifying the day of the week of a date. By default
the day ranges from 1 (Sunday) to 7 (Saturday).
Syntax: WEEKDAY(<date>, <return_type>)
Term Definition
WEEKDAY date The date in datetime format.
return_type A number that determines the return value: Return type: 1, week begins on
Sunday (1) and ends on Saturday (7). numbered 1 through 7. Return type: 2,
week begins on Monday (1) and ends on Sunday (7). Return type: 3, week begins
on Monday (0) and ends on Sunday (6) numbered 1 through .
1 WWW.DATALYTICSACADEMY.COM
Returns the week number for the given date and year according to the return_type value. The
week number indicates where the week falls numerically within a year.
Syntax: WEEKNUM(<date>, <return_type>)
Term Definition
Time Intelligence Functions Intelligence analysis by enabling you to manipulate data using
time periods, including days, months, quarters, and years, and
then build and compare calculations over those periods.
Returns a table that contains a column of dates, shifted either forward or backward in time by the
specified number of intervals from the dates in the current context.
Syntax: DATEADD(<dates>,<number_of_intervals>,<interval>)
Term Definition
DATEADD dates A column that contains dates.
interval The interval by which to shift the dates. The value for interval can be
one of the following: year, quarter, month, day
Description: Returns the first date in the current context for the specified column of dates.
FIRSTDATE Syntax: FIRSTDATE(<dates>)
Dates = A column that contains dates
Description: Returns a table that contains a column of the dates for the month to date, in the
current context.
DATESMTD Sytnax: DATESMTD(<dates>)
Dates = A column that contains dates
Interchangeable: MTD can be exchanged out for QTD or YTD.
Description: Returns a table that contains a column of all dates from the next day, based on the
first date specified in the dates column in the current context.
NEXTDAY Sytnax: NEXTDAY(<dates>)
Dates = A column that contains dates
Interchangeable: DAY can be exchanged out for MONTH, QUARTER, or YEAR.
2 WWW.DATALYTICSACADEMY.COM
Returns a table that contains a column of all dates representing the day that is previous to the
first date in the dates column, in the current context.
PREVIOUSDAY Sytnax: PREVIOUSDAY(<dates>)
Dates = A column that contains dates
Interchangeable: DAY can be exchanged out for MONTH, QUARTER, or YEAR.
Description: Evaluates the value of the expression for the month to date, in the current context.
Syntax: TOTALMTD(<expression>,<dates>[,<filter>])
Parameter Definition
TOTALMTD
expression An expression that returns a scalar value.
filter (optional) An expression that specifies a filter to apply to the current context.
Interchangeable: MTD can be exchanged out for QTD or YTD.
The filter and value functions in DAX are some of the most
complex and powerful, and differ greatly from Excel functions.
Filter Functions The lookup functions work by using tables and relationships,
like a database. The filtering functions let you manipulate data
context to create dynamic calculations.
Description: Returns all the rows in a table, or all the values in a column, ignoring any filters that
might have been applied. This function is useful for clearing filters and creating calculations on all
the rows in a table.
Syntax: ALL( {<table> | <column>[, <column>[, <column>[,…]]]} )
Parameter Definition
ALL
table The table that you want to clear filters on.
Note: The argument to the ALL function must be either a reference to a table or a reference to a
base column. You cannot use table expressions or column expressions with the ALL function.
Description: Evaluates an expression in a context that is modified by the specified filters.
Syntax: CALCULATE(<expression>,<filter1>,<filter2>…)
Parameter Definition
CALCULATE
expression The expression to be evaluated.
Description: Returns a one-column table that contains the distinct values from the specified
column. In other words, duplicate values are removed and only unique values are returned.
DISTINCT Syntax: DISTINCT(<column>)
<column>= The column from which unique values are to be returned. Or, an expression that
returns a column.
3 WWW.DATALYTICSACADEMY.COM
Note: This function cannot be used to return values into a cell or column on a worksheet;
rather, you nest the DISTINCT function within a formula, to get a list of distinct values that can
be passed to another function and then counted, summed, or used for other operations.
filter A Boolean expression that is to be evaluated for each row of the table. For
example, [Amount] > 0 or [Region] = "France"
Description: Returns the values that are directly applied as filters to columnName.
Syntax: FILTERS(<columnName>)
FILTERS <columnName>= The name of an existing column, using standard DAX syntax. It cannot be an
expression.
Description: Returns a one-column table that contains the distinct values from the specified table
or column. In other words, duplicate values are removed and only unique values are returned.
Syntax: VALUES(<TableNameOrColumnName>)
<TableNameOrColumnName>= The table or column from which unique values are to be
VALUES returned.
Note: This function cannot be used to return values into a cell or column on a worksheet;
rather, you use it as an intermediate function, nested in a formula, to get a list of distinct values
that can be counted, or used to filter or sum other values.
Information Functions provided as an argument and tells you whether the value
matches the expected type. For example, the ISERROR function
returns TRUE if the value that you reference contains an error.
Description: Returns true if values for all referred columns exist, or are contained, in those
columns; otherwise, the function returns false.
Syntax: CONTAINS(<table>, <columnName>, <value>[, <columnName>, <value>]…)
Parameter Definition
4 WWW.DATALYTICSACADEMY.COM
Description: Checks whether a value is an error, and returns TRUE or FALSE.
ISERROR Syntax: ISERROR (<value>)
Value = The value or expression you want to test.
Description: Checks whether a value is even, and returns TRUE or FALSE.
ISEVEN Syntax: ISEVEN (<value>)
Value = The value you want to test.
Note you can also use ISODD
Returns the value in result_columnName for the row that meets all criteria specified
by search_columnName and search_value.
Syntax: LOOKUPVALUE( <result_columnName>, <search_columnName>,
<search_value>[, <search_columnName>, <search_value>]…)
Parameter Definition
result_columnName The name of an existing column that contains the value you
want to return. The column must be named using standard DAX
LOOKUPVALUE syntax, usually, fully qualified. It cannot be an expression.
search_value A scalar expression that does not refer to any column in the
same table being searched
Logical Functions about the values or sets in the expression. For example, you
can use the IF function to check the result of an expression and
create conditional results.
Description: Checks whether both arguments are TRUE, and returns TRUE if both arguments are
AND TRUE. Otherwise returns false.
Syntax: AND(<logical1>,<logical2>)
Logica1, Logical2 = The logical values you want to test.
value_if_false The value that is returned if the logical test is FALSE. If omitted,
FALSE is returned.
Description: Evaluates an expression and returns a specified value if the expression returns an
IFERROR error; otherwise returns the value of the expression itself.
Syntax: IFERROR(value, value_if_error)
5 WWW.DATALYTICSACADEMY.COM
Parameter Definition
Math Functions
Description: Returns the absolute value of a number.
ABS Syntax: ABS(<number>)
Number: The Number which you want the absolute value
Description: Returns the number of combinations for a given number of items. Use COMBIN to
determine the total possible number of groups for a given number of items.
Syntax: COMBIN(number, number_chosen)
Parameter Definition
COMBIN
number The number of items.
Description: Rounds a number down, toward zero, to the nearest multiple of significance.
Syntax: FLOOR(<number>, <significance>)
Parameter Definition
FLOOR
number The numeric value you want to round.
6 WWW.DATALYTICSACADEMY.COM
significance The multiple to which you want to round. The
argumentsnumber and significance must either both be positive,
or both be negative.
Note: FLOOR can be interchanged for CEILING to round up to the nearest multiple of
significance.
Description: Rounds a number down to the nearest integer.
INT Syntax: INT(<number>)
Number: The number you want to round down to an integer.
Description: Returns the product of the numbers in a column. To return the product of an
expression evaluated for each row in a table, use PRODUCTX
PRODUCT Syntax: SUM(<column>)
Column: The column that contains the numbers to sum.
Note: Only the numbers in the column are counted. Blanks, logical values, and text are ignored.
PRODUCT( Table[Column] ) is equivalent to PRODUCTX( Table, Table[Column] )
Description: Returns the product of an expression evaluated for each row in a table. To return
the product of the numbers in a column
Syntax: PRODUCTX(<table>, <expression>)
PRODUCTX Column: The column that contains the numbers to sum.
Note: The PRODUCTX function takes as its first argument a table, or an expression that returns a
table. The second argument is a column that contains the numbers for which you want to
compute the product, or an expression that evaluates to a column.
Description: Adds all the numbers in a column.
SUM Syntax: SUM(<column>)
Column: The column that contains the numbers to sum.
Description: Returns the sum of an expression evaluated for each row in a table.
Syntax: SUMX(<table>, <expression>)
Parameter Definition
SUMX table The table containing the rows for which the expression will be
evaluated.
Description: Returns the average (arithmetic mean) of all the numbers in a column.
AVERAGE Syntax: AVERAGE(<column>)
Column: The column that contains the numbers take the average of.
Description: The COUNT function counts the number of cells in a column that contain numbers.
COUNT Syntax: COUNT(<column>)
Column: The column that contains the numbers to be counted.
7 WWW.DATALYTICSACADEMY.COM
Note:
COUNTA counts cells which are not blank.
COUNTX counts the number of rows that contain a number or an expression that
evaluates to a number, when evaluating an expression over a table.
COUNTAX counts nonblank results when evaluating the result of an expression
over a table. That is, it works just like the COUNTA function, but is used to
iterate through the rows in a table and count rows where the specified
expressions results in a nonblank result.
Description: The DISTINCTCOUNT function counts the number of distinct values in a column.
DISTINCTCOUNT Syntax: DISTINCTCOUNT(<column>)
Column: The column that contains the numbers you want to count.
Description: Returns a table with the Cartesian product between each row in table1 and the table
that results from evaluating table2 in the context of the current row from table1.
Syntax: GENERATE(<table1>, <table2>)
Parameter Definition
GENERATE
Table1 Any DAX expression that returns a table.
Description: Returns the largest numeric value in a column, OR between two scalar expressions.
Syntax: MAX(<column>)
Syntax: MAX(<expression1>, <expression2>)
Parameter Definition
column The column in which you want to find the largest numeric value.
Note:
MAXA Returns the largest value in a column. Logical values and blanks are counted, where as
MAX only recognizes numeric values
MAXX Evaluates an expression for each row of a table and returns the largest numeric value.
MINA and MINX can be interchanged to return the lowest values.
Description: Returns the median of numbers in a column.
MEDIAN Syntax: MEDIAN(<column>)
Column: The column that contains the numbers for which the median is to be computed.
Note: MEDIANX will return the median of an expression evaluated for each row in a table.
Description: Returns the median number of an expression evaluated for each row in a table.
Syntax: MEDIANX(<table>, <expression>
MEDIANX Parameter Definition
8 WWW.DATALYTICSACADEMY.COM
expression The expression to be evaluated for each row of the table.
Description: Returns the sum of an expression evaluated for each row in a table.
Syntax: SUMX(<table>, <expression>)
Parameter Definition
SUMX table The table containing the rows for which the expression will be
evaluated.
Text Functions that is based on the library of string functions in Excel, but which
has been modified to work with tables and columns. This section
lists all text functions available in the DAX language.
Description: Compares two text strings and returns TRUE if they are exactly the same, FALSE
otherwise. EXACT is case-sensitive but ignores formatting differences. You can use EXACT to test
text being entered into a document.
Syntax: EXACT(<text1>,<text2>)
EXACT Parameter Definition
Description: Returns the starting position of one text string within another text string. FIND is
case-sensitive.
Syntax: FIND(<find_text>, <within_text>[, [<start_num>][,
<NotFoundValue>]])
Parameter Definition
FIND find_text The text you want to find. Use double quotes (empty text) to
match the first character in within_text.
You can use wildcard characters — the question mark (?) and
asterisk (*) — in find_text. A question mark matches any single
character; an asterisk matches any sequence of characters. If
9 WWW.DATALYTICSACADEMY.COM
you want to find an actual question mark or asterisk, type a tilde
(~) before the character.
Description: Returns the specified number of characters from the start of a text string.
Syntax: LEFT(<text>, <num_chars>)
Parameter Definition
LEFT text The text string containing the characters you want to extract, or
a reference to a column that contains text.
Description: Returns a string of characters from the middle of a text string, given a starting
position and length.
Syntax: MID(<text>, <start_num>, <num_chars>)
Parameter Definition
text The text string from which you want to extract the characters, or
MID a column that contains text.
start_num The position of the first character you want to extract. Positions
start at 1.
Description: RIGHT returns the last character or characters in a text string, based on the number
of characters you specify.
RIGHT Syntax: RIGHT(<text>, <num_chars>)
Parameter Definition
10 WWW.DATALYTICSACADEMY.COM
text The text string that contains the characters you want to extract,
or a reference to a column that contains text.
Description: Returns the number of the character at which a specific character or text string is first
found, reading left to right. Search is case-insensitive and accent sensitive.
Syntax: SEARCH(<find_text>, <within_text>[, [<start_num>][,
<NotFoundValue>]])
Parameter Definition
You can use wildcard characters — the question mark (?) and
asterisk (*) — in find_text. A question mark matches any single
character; an asterisk matches any sequence of characters. If you
want to find an actual question mark or asterisk, type a tilde (~)
SEARCH before the character.
within_text The text in which you want to search for find_text, or a column
containing text.
11 WWW.DATALYTICSACADEMY.COM