DAX Functions SUMMARY
DAX Functions SUMMARY
DAX functions can be categorized into several groups. Below, we’ll elaborate on each category with
detailed explanations and multiple examples.
Aggregate Functions
Aggregate functions perform calculations on a set of values and return a single value.
1. SUM()
Adds up all the values in a specified column.
Calculates the total sales amount from the `SalesAmount` column in the `Sales` table.
Calculates the total quantity sold from the `Quantity` column in the `Sales` table.
2. AVERAGE()
Calculates the average of values in a specified column.
3. COUNT()
Counts the number of rows in a column that contain numbers.
Counts the total number of sales transactions based on the `SalesID` column.
4. COUNTA()
Counts the number of non-empty values in a column.
5. MIN()
Returns the smallest value in a column.
6. MAX()
Returns the largest value in a column.
Example 1: Maximum Sales Amount
---
Logical Functions
Logical functions perform logical operations and return TRUE or FALSE.
1. IF()
Evaluates a condition and returns one value if TRUE, another if FALSE.
2. AND()
Returns TRUE if all conditions are TRUE.
3. OR()
Returns TRUE if at least one condition is TRUE.
4. NOT()
Reverses the value of a logical expression.
---
Text Functions
Text functions manipulate text strings.
1. CONCATENATE()
Joins two text strings into one.
Example 2: Address
2. LEN()
Returns the length of a text string.
3. LEFT()
Returns the specified number of characters from the start of a text string.
4. RIGHT()
Returns the specified number of characters from the end of a text string.
Example 1: Last Three Characters of Product SKU
5. UPPER()
Converts a text string to uppercase.
6. LOWER()
Converts a text string to lowercase.
---
Date and Time Functions
These functions work with date and time values.
1. TODAY()
Returns the current date.
Calculates the number of days since the start of the current year.
2. NOW()
Returns the current date and time.
3. YEAR()
Extracts the year from a date.
4. MONTH()
Extracts the month from a date.
5. DAY()
Extracts the day from a date.
6. DATEDIFF()
Calculates the difference between two dates.
---
Filter Functions
These functions modify filter context for calculations.
1. FILTER()
Returns a table that has been filtered based on a condition.
2. ALL()
Removes filters from a table or column.
Calculates total sales ignoring any filters applied to the `Sales` table.
3. CALCULATE()
Changes the context in which data is evaluated.
4. VALUES()
Returns a one-column table that contains the distinct values from the specified column.
---
1. TOTALYTD()
Calculates year-to-date values.
Calculates total sales from the beginning of the year to the current date.
Example 2: Year-to-Date Profit
2. SAMEPERIODLASTYEAR()
Compares values from the same period in the previous year.
3. DATEADD()
Shifts dates by a specified number of intervals.
4. PREVIOUSYEAR()
Returns the previous year.