0% found this document useful (0 votes)
5 views11 pages

DAX in Power BI: Explanation and 50 Most Used DAX Formulas

Uploaded by

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

DAX in Power BI: Explanation and 50 Most Used DAX Formulas

Uploaded by

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

DAX in Power BI: Explanation and 50 Most Used DAX Formulas

What is DAX in Power BI?

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,

and tables within Power BI.

DAX helps in:

1. Creating custom calculations in your data models.

2. Creating aggregations, filters, and relationships.

3. Enabling complex business logic in your visualizations.

50 Most Used DAX Formulas (Explained with Examples)

1. SUM

Adds up all the values in a column.

Example:

SUM(Sales[Amount])

This calculates the total sales amount.

2. AVERAGE
Calculates the average of all values in a column.

Example:

AVERAGE(Sales[Amount])

Finds the average sales amount.

3. COUNT

Counts the number of rows in a column.

Example:

COUNT(Sales[OrderID])

Counts the total number of orders.

4. COUNTA

Counts non-blank rows in a column.

Example:

COUNTA(Sales[ProductName])

Counts the products with non-blank names.

5. COUNTROWS

Counts the number of rows in a table.

Example:

COUNTROWS(Sales)

Counts all rows in the Sales table.

6. DISTINCTCOUNT

Counts distinct values in a column.

Example:

DISTINCTCOUNT(Sales[CustomerID])

Counts unique customers.

7. MAX
Returns the largest value in a column.

Example:

MAX(Sales[Amount])

Finds the highest sales amount.

8. MIN

Returns the smallest value in a column.

Example:

MIN(Sales[Amount])

Finds the smallest sales amount.

9. DIVIDE

Performs division and handles divide-by-zero errors.

Example:

DIVIDE(SUM(Sales[Profit]), SUM(Sales[Revenue]))

Calculates profit margin.

10. RELATED

Fetches related values from another table.

Example:

RELATED(Products[ProductCategory])

Fetches the product category for each sale.

11. ALL

Removes filters from a table or column.

Example:

ALL(Sales[Region])

Ignores region filters in calculations.

12. CALCULATE
Changes context and applies filters.

Example:

CALCULATE(SUM(Sales[Amount]), Sales[Region] = "East")

Calculates sales only for the East region.

13. FILTER

Returns a filtered table.

Example:

FILTER(Sales, Sales[Amount] > 1000)

Gets sales greater than 1000.

14. EARLIER

Refers to an earlier row context.

Example:

Sales[Amount] - EARLIER(Sales[Amount])

Calculates the difference between current and earlier row amounts.

15. VALUES

Returns unique values from a column.

Example:

VALUES(Sales[Region])

Lists unique regions.

16. LOOKUPVALUE

Returns the value corresponding to a specific condition.

Example:

LOOKUPVALUE(Products[Price], Products[ProductID], Sales[ProductID])

Gets the price for each product in sales.

17. IF
Returns different results based on a condition.

Example:

IF(Sales[Amount] > 1000, "High", "Low")

Categorizes sales as High or Low.

18. SWITCH

Similar to nested IF statements.

Example:

SWITCH(Sales[Category], "A", 1, "B", 2, 0)

Returns 1 for category A, 2 for B, and 0 otherwise.

19. CONCATENATE

Combines two strings.

Example:

CONCATENATE(Sales[FirstName], Sales[LastName])

Combines first and last names.

20. CONCATENATEX

Concatenates values in a column with a delimiter.

Example:

CONCATENATEX(Sales, Sales[ProductName], ", ")

Lists product names separated by commas.

21. ISBLANK

Checks if a value is blank.

Example:

ISBLANK(Sales[Amount])

Returns TRUE for blank sales amounts.

22. BLANK
Returns a blank value.

Example:

IF(Sales[Amount] = 0, BLANK(), Sales[Amount])

Replaces zero amounts with blanks.

23. YEAR

Extracts the year from a date.

Example:

YEAR(Sales[OrderDate])

Gets the year of the order date.

24. MONTH

Extracts the month from a date.

Example:

MONTH(Sales[OrderDate])

Gets the month of the order date.

25. FORMAT

Formats values as strings.

Example:

FORMAT(Sales[Amount], "Currency")

Displays amounts in currency format.

26. NOW

Returns the current date and time.

Example:

NOW()

Displays the current date-time.

27. TODAY
Returns the current date.

Example:

TODAY()

Displays today's date.

28. DATEDIFF

Calculates the difference between two dates.

Example:

DATEDIFF(Sales[StartDate], Sales[EndDate], DAY)

Finds the duration in days.

29. DISTINCT

Returns a table with distinct values.

Example:

DISTINCT(Sales[Region])

Lists distinct regions.

30. RANKX

Ranks values in a column.

Example:

RANKX(ALL(Sales), Sales[Amount])

Ranks sales amounts.

31. TOPN

Returns the top N rows from a table.

Example:

TOPN(5, Sales, Sales[Amount])

Gets the top 5 sales amounts.

32. PERCENTILE.EXC
Returns the nth percentile (exclusive).

Example:

PERCENTILE.EXC(Sales[Amount], 0.9)

Finds the 90th percentile of sales.

33. MEDIAN

Calculates the median of a column.

Example:

MEDIAN(Sales[Amount])

Finds the middle value in sales amounts.

34. ROUND

Rounds numbers to a specified number of digits.

Example:

ROUND(Sales[Amount], 2)

Rounds sales amounts to two decimal places.

35. ROUNDUP

Rounds numbers up.

Example:

ROUNDUP(Sales[Amount], 0)

Rounds amounts up to the nearest integer.

36. ROUNDDOWN

Rounds numbers down.

Example:

ROUNDDOWN(Sales[Amount], 0)

Rounds amounts down to the nearest integer.

37. POWER
Returns the result of a number raised to a power.

Example:

POWER(Sales[Amount], 2)

Squares the sales amount.

38. EXP

Calculates the exponential of a number.

Example:

EXP(1)

Returns e (Euler's number).

39. LOG

Returns the logarithm of a number.

Example:

LOG(Sales[Amount], 10)

Finds the base-10 logarithm.

40. TRUNC

Truncates a number to an integer.

Example:

TRUNC(Sales[Amount])

Removes decimal places.

41. ABS

Returns the absolute value.

Example:

ABS(Sales[Profit])

Removes negative signs from profit.

42. LEFT
Returns a specified number of characters from the start of a string.

Example:

LEFT(Sales[ProductName], 5)

Gets the first 5 characters of product names.

43. RIGHT

Returns a specified number of characters from the end of a string.

Example:

RIGHT(Sales[ProductName], 3)

Gets the last 3 characters of product names.

44. MID

Extracts a substring from a string.

Example:

MID(Sales[ProductName], 3, 4)

Gets 4 characters starting from the 3rd character.

45. LEN

Returns the length of a string.

Example:

LEN(Sales[ProductName])

Finds the number of characters in product names.

46. REPLACE

Replaces part of a string with another string.

Example:

REPLACE(Sales[ProductName], 1, 3, "New")

Replaces the first 3 characters with "New".

47. SUBSTITUTE
Replaces occurrences of a substring.

Example:

SUBSTITUTE(Sales[ProductName], "Old", "New")

Replaces "Old" with "New" in product names.

48. SEARCH

Finds the position of a substring.

Example:

SEARCH("Pro", Sales[ProductName])

Finds the position of "Pro" in product names.

49. TRIM

Removes extra spaces from text.

Example:

TRIM(Sales[ProductName])

Cleans up product names.

50. UPPER

Converts text to uppercase.

Example:

UPPER(Sales[ProductName])

Changes product names to uppercase.

You might also like