0% found this document useful (0 votes)
11 views

Syntax of DAX

Uploaded by

divyanshu.sri19
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
11 views

Syntax of DAX

Uploaded by

divyanshu.sri19
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Aggregation Functions

These functions aggregate values over a column or a table.

 SUM

SUM(column)

 AVERAGE

AVERAGE(column)

 MIN

MIN(column)

 MAX

MAX(column)

 COUNT

COUNT(column)

 COUNTROWS

COUNTROWS(table)

2. Iterating Functions

These functions perform row-by-row calculations.

 SUMX

SUMX(table, expression)

 AVERAGEX

AVERAGEX(table, expression)

 MINX

MINX(table, expression)

 MAXX

MAXX(table, expression)
 RANKX

RANKX(table, expression, [value], [order], [ties])

3. Logical Functions

These functions evaluate logical conditions.

 IF

IF(condition, true_result, [false_result])

 SWITCH

SWITCH(expression, value1, result1, [value2, result2, ...], [else])

 AND

AND(condition1, condition2)

 OR

OR(condition1, condition2)

4. Filter Functions

These functions modify or return filtered data.

 CALCULATE

CALCULATE(expression, [filter1], [filter2], ...)

 FILTER

FILTER(table, condition)

 ALL

ALL(column)

 ALLEXCEPT

ALLEXCEPT(table, column1, column2, ...)

 REMOVEFILTERS

REMOVEFILTERS([column])
5. Time Intelligence Functions

These functions are used to perform calculations on date and time data.

 TOTALYTD

TOTALYTD(expression, dates, [year_end_date], [filter])

 SAMEPERIODLASTYEAR

SAMEPERIODLASTYEAR(dates)

 DATESYTD

DATESYTD(dates, [year_end_date])

 PREVIOUSMONTH

PREVIOUSMONTH(dates)

6. Mathematical and Trigonometric Functions

These functions perform mathematical operations.

 ABS

ABS(number)

 CEILING

CEILING(number, significance)

 FLOOR

FLOOR(number, significance)

 ROUND

ROUND(number, num_digits)

 TRUNC

TRUNC(number, num_digits)
7. Text Functions

These functions perform operations on text strings.

 CONCATENATE

CONCATENATE(text1, text2)

 LEFT

LEFT(text, num_chars)

 RIGHT

RIGHT(text, num_chars)

 MID

MID(text, start_num, num_chars)

 LEN

LEN(text)

 SEARCH

SEARCH(find_text, within_text, [start_num], [not_found_value])

8. Date and Time Functions

These functions perform operations on date and time data.

 TODAY

TODAY()

 NOW

NOW()

 YEAR

YEAR(date)

 MONTH

MONTH(date)
 DAY

DAY(date)

 HOUR

HOUR(time)

 MINUTE

MINUTE(time)

 SECOND

SECOND(time)

Examples of Different Types of DAX Expressions

1. Aggregation Function Example:

TotalSales = SUM(Sales[SalesAmount])

2. Iterating Function Example:

TotalProfit = SUMX(Sales, Sales[SalesAmount] - Sales[Cost])

3. Logical Function Example:

HighValueSales = IF(Sales[SalesAmount] > 1000, "High", "Low")

4. Filter Function Example:

CategorySales = CALCULATE(SUM(Sales[SalesAmount]), Sales[Category] =


"Electronics")

5. Time Intelligence Function Example:

YTDSales = TOTALYTD(SUM(Sales[SalesAmount]), Sales[OrderDate])

6. Mathematical Function Example:

RoundedSales = ROUND(Sales[SalesAmount], 2)

7. Text Function Example:

FullName = CONCATENATE(Customer[FirstName], " " & Customer[LastName])


8. Date and Time Function Example:

OrderYear = YEAR(Sales[OrderDate])

These examples and syntaxes cover a wide range of DAX expressions used for different
purposes in data analysis.

You might also like