DAX in Power BI: Explanation and 50 Most Used DAX Formulas
DAX in Power BI: Explanation and 50 Most Used DAX Formulas
DAX (Data Analysis Expressions) is a formula language used in Power BI, Power Pivot, and
Analysis Services.
It is designed to work with relational data and provides a way to perform data analysis and
calculations
on data models. DAX is similar to Excel formulas but is optimized for creating calculated columns,
measures,
1. SUM
Example:
SUM(Sales[Amount])
2. AVERAGE
Calculates the average of all values in a column.
Example:
AVERAGE(Sales[Amount])
3. COUNT
Example:
COUNT(Sales[OrderID])
4. COUNTA
Example:
COUNTA(Sales[ProductName])
5. COUNTROWS
Example:
COUNTROWS(Sales)
6. DISTINCTCOUNT
Example:
DISTINCTCOUNT(Sales[CustomerID])
7. MAX
Returns the largest value in a column.
Example:
MAX(Sales[Amount])
8. MIN
Example:
MIN(Sales[Amount])
9. DIVIDE
Example:
DIVIDE(SUM(Sales[Profit]), SUM(Sales[Revenue]))
10. RELATED
Example:
RELATED(Products[ProductCategory])
11. ALL
Example:
ALL(Sales[Region])
12. CALCULATE
Changes context and applies filters.
Example:
13. FILTER
Example:
14. EARLIER
Example:
Sales[Amount] - EARLIER(Sales[Amount])
15. VALUES
Example:
VALUES(Sales[Region])
16. LOOKUPVALUE
Example:
17. IF
Returns different results based on a condition.
Example:
18. SWITCH
Example:
19. CONCATENATE
Example:
CONCATENATE(Sales[FirstName], Sales[LastName])
20. CONCATENATEX
Example:
21. ISBLANK
Example:
ISBLANK(Sales[Amount])
22. BLANK
Returns a blank value.
Example:
23. YEAR
Example:
YEAR(Sales[OrderDate])
24. MONTH
Example:
MONTH(Sales[OrderDate])
25. FORMAT
Example:
FORMAT(Sales[Amount], "Currency")
26. NOW
Example:
NOW()
27. TODAY
Returns the current date.
Example:
TODAY()
28. DATEDIFF
Example:
29. DISTINCT
Example:
DISTINCT(Sales[Region])
30. RANKX
Example:
RANKX(ALL(Sales), Sales[Amount])
31. TOPN
Example:
32. PERCENTILE.EXC
Returns the nth percentile (exclusive).
Example:
PERCENTILE.EXC(Sales[Amount], 0.9)
33. MEDIAN
Example:
MEDIAN(Sales[Amount])
34. ROUND
Example:
ROUND(Sales[Amount], 2)
35. ROUNDUP
Example:
ROUNDUP(Sales[Amount], 0)
36. ROUNDDOWN
Example:
ROUNDDOWN(Sales[Amount], 0)
37. POWER
Returns the result of a number raised to a power.
Example:
POWER(Sales[Amount], 2)
38. EXP
Example:
EXP(1)
39. LOG
Example:
LOG(Sales[Amount], 10)
40. TRUNC
Example:
TRUNC(Sales[Amount])
41. ABS
Example:
ABS(Sales[Profit])
42. LEFT
Returns a specified number of characters from the start of a string.
Example:
LEFT(Sales[ProductName], 5)
43. RIGHT
Example:
RIGHT(Sales[ProductName], 3)
44. MID
Example:
MID(Sales[ProductName], 3, 4)
45. LEN
Example:
LEN(Sales[ProductName])
46. REPLACE
Example:
REPLACE(Sales[ProductName], 1, 3, "New")
47. SUBSTITUTE
Replaces occurrences of a substring.
Example:
48. SEARCH
Example:
SEARCH("Pro", Sales[ProductName])
49. TRIM
Example:
TRIM(Sales[ProductName])
50. UPPER
Example:
UPPER(Sales[ProductName])