0% found this document useful (0 votes)
55 views9 pages

7 DAX Functions For Power BI

Uploaded by

lsbexcel
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)
55 views9 pages

7 DAX Functions For Power BI

Uploaded by

lsbexcel
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/ 9

2024

7
DAX Functions
for Power BI
You Must Learn

Azdine Bahloul
Data Analyst
1. SUMX
Syntax:

SUMX(<table>, <expression>)

Explanation:
SUMX evaluates an expression for each row in a table and returns the
sum of the results.

Description:
This function is commonly used to perform row-by-row calculations
before summing the results, ideal for multiplying columns or applying
complex calculations.

Example of Measure:

Total Sales = SUMX(


Sales,
Sales[Quantity] * Sales[Unit Price]
)

This measure calculates the total sales by multiplying quantity and unit
price for each row in the Sales table.

Azdine Bahloul
Data Analyst
2. CALCULATE
Syntax:

CALCULATE(<expression>, <filter1>, <filter2>, ...)

Explanation:
CALCULATE changes the context in which data is evaluated, applying
filters to your expression dynamically.

Description:
This is one of the most powerful DAX functions that allows you to apply
filters and modify the context of your data, making it useful for filtered
aggregations.

Example of Measure:

Sales for 2023 = CALCULATE(


[Total Sales],
Sales[Year] = 2023
)

This measure calculates total sales but only for the year 2023 by
applying the year filter.

Azdine Bahloul
Data Analyst
3. FILTER
Syntax:

FILTER(<table>, <expression>)

Explanation:
FILTER returns a subset of rows from a table that meet a specific
condition, refining your data for detailed analysis.

Description:
It allows you to apply conditions to rows in a table, which is useful for
narrowing down data based on specific criteria.

Example of Measure:

Filtered Sales = CALCULATE(


[Total Sales],
FILTER(
Sales,
Sales[Quantity] > 10
)
)

This measure calculates total sales but only for rows where the quantity
is greater than 10.

Azdine Bahloul
Data Analyst
4. ALL
Syntax:

ALL(<table> | <column>)

Explanation:
ALL removes all filters from the specified table or column, allowing you
to analyze data in its entirety without any filtering.

Description:
This function is particularly useful when you want to calculate values
disregarding any existing filters on a column or table.

Example of Measure:

Total Sales All Years = CALCULATE(


[Total Sales],
ALL(Sales[Year])
)

This measure calculates the total sales without considering any filter
applied to the Year column.

Azdine Bahloul
Data Analyst
5. RELATED
Syntax:

RELATED(<column>)

Explanation:
RELATED retrieves a value from a related table, based on relationships
set in the model, allowing you to access data across tables.

Description:
It’s used to bring in values from related tables when you're working with
data models that have relationships defined.

Example of Measure:

Product Category Sales = SUMX(


Sales,
Sales[Quantity] * RELATED(Product[Category])
)

This measure calculates sales by multiplying quantity and fetching


product categories from the related Product table.

Azdine Bahloul
Data Analyst
6. DIVIDE
Syntax:

DIVIDE(<numerator>, <denominator>, <alternateResult>)

Explanation:
DIVIDE performs division and handles cases where the denominator
might be zero, preventing errors in your calculation.

Description:
This function helps avoid division by zero errors by specifying an
alternate result to return when the denominator is zero.

Example of Measure:

Profit Margin = DIVIDE(


[Total Profit],
[Total Sales],
0
)

This measure calculates the profit margin and ensures no errors by


returning 0 when total sales is zero.

Azdine Bahloul
Data Analyst
7. DISTINCTCOUNT
Syntax:

DISTINCTCOUNT(<column>)

Explanation:
DISTINCTCOUNT counts the number of unique values in a column, useful
for finding distinct items like customers or products.

Description:
This function is excellent for counting distinct or unique values in a
dataset, such as identifying unique customers or products.

Example of Measure:

Unique Customers = DISTINCTCOUNT(


Sales[CustomerID]
)

This measure counts the number of unique customers based on their


CustomerID.

Azdine Bahloul
Data Analyst
Did you like it ?

So,
Did you know them all?

Let me know in the comments !

You might also like