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

Dax Function 1691309897

Dax guide

Uploaded by

8mwhxgdm85
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)
36 views

Dax Function 1691309897

Dax guide

Uploaded by

8mwhxgdm85
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

Advanced DAX

Functions and
Concepts in Power BI

My LinkedIn Profile My all Links


Shraddha Shukla
CALCULATE

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

The CALCULATE function modifies the filter context for a given expression. It
allows you to apply additional filters or conditions to a calculation.

Example: Calculate total sales for the year 2023, regardless of any filters on the
visual:

Total Sales 2023 =CALCULATE([Total Sales],FILTER('Date', 'Date'[Year] = 2023))


FILTER

Formula: FILTER(<table>, <condition>)


The FILTER function creates a new table with rows that satisfy a
specified condition.
Example: Calculate the number of products with sales greater
than $100:
High Sales Products =
COUNTROWS(FILTER('Products','Products'[Total Sales] > 10)))
ALL
Formula: ALL(<table/column>)
The ALL function removes filters from a specified table or
column, providing a way to evaluate calculations without certain
filters.
Example: Calculate the total sales ignoring any filters on the
'Category' column:

Total Sales (All Categories) = SUMX(ALL('Products'[Category]),


[Total Sales])
SUMX / AVERAGEX

Formula: SUMX(<table>, <expression>) / AVERAGEX(<table>,


<expression>)
These functions iterate through each row in a table, evaluate an
expression, and then aggregate the results.
Example: Calculate the total profit for each product and then
average the profits:

Average Profit per Product = AVERAGEX('Products',[Total Profit])


RELATED / RELATEDTABLE

Formula: RELATED(<column>) / RELATEDTABLE(<table>)


These functions retrieve values from related tables based on
established relationships.
Example: Calculate the average price of products in the related
'Product' table:

Average Related Price = AVERAGEX('Sales',


RELATED('Products'[Price]))
EARLIER

Formula: EARLIER(<expression>)
The EARLIER function is used to refer to a value in an outer
evaluation context, usually within iterating functions.
Example: Calculate the cumulative profit for each product up to
the current row:

Cumulative Profit = SUMX(FILTER('Products','Products'[Date] <=


EARLIER('Products'[Date])
),'Products'[Profit])
SWITCH
Formula: SWITCH(<expression>, <value1>, <result1>, <value2>,
<result2>, ...)
The SWITCH function is used for conditional logic similar to a
switch-case statement.
Example: Assign a category to sales based on ranges:
Sales Category =
SWITCH(
TRUE(),
[Total Sales] < 1000, "Low",
[Total Sales] < 5000, "Medium",
"High")
Shraddha Shukla

You might also like