? Dax Functions in Power BI
? Dax Functions in Power BI
Power BI
Function
Example This brings in 'Price' from
the related 'Product'
table.
SUMX(Sales,
SUMX Sales[Quantity] *
Sales[Price])
Function
This sums after
Example calculating
Quantity * Price.
RANKX(ALL(Sales),
RANKX Sales[Amount])
Function
Example This ranks sales by
'Amount'.
DATEADD(Sales[Date],
DATEADD 1, MONTH)
Function
Example This adds 1 month to
the dates in the 'Date'
column.
DATEDIFF(Sales[StartDate],
Function
Example This calculates the
difference between dates
in days.
SAMEPERIODLAST
YEAR(Sales[Date])
SAMEPERIODLASTYEAR
Function Example
Function
Example This returns the
year-to-date total.
PREVIOUSMONTH(Sales[Date])
PREVIOUSMONTH
Function Example
Function
This returns 'High' if
Example the Amount is
greater than 100,
otherwise 'Low'.
SWITCH(TRUE(),
Sales[Amount] > 100,
SWITCH "High", Sales[Amount]
<= 100, "Low")
Function
Example This applies multiple
conditions.
ISBLANK ISBLANK(Sales[Amount])
Function
Example This checks if the
'Amount' column is
blank.
CONCATENATEX(Sales,
Sales[ProductName], ",
")
CONCATENATEX
Function
Example
This concatenates
product names with a
comma.
FORMAT(Sales[Amount],
FORMAT "Currency")
Function
Example This formats the
'Amount' as currency.
DIVIDE(Sales[Amount],
Sales[Quantity], 0)
Example Syntax :
DIVIDE(<numerator>,
<denominator>,
<alternateResult>
MAX MAX(Sales[Amount])
Function
This returns the
Example maximum value in
the 'Amount'
column.
MIN MIN(Sales[Amount])
Function
This returns the
Example minimum value in
the 'Amount'
column.
TOPN(5, Sales,
TOPN Sales[Amount])
Function
This returns the
Example top 5 rows based
on the 'Amount'.
ALLEXCEPT(Sales,
Sales[ProductID])
ALLEXCEPT
Function
Example This removes all
filters except on
'ProductID'.
SELECTEDVALUE SELECTEDVALUE(Sales[Region])
Function
Example This returns the selected value
from the 'Region' column.
HASONEVALUE(Sales[P
roductID])
HASONEVALUE
Function
Example
This checks if only one
value is selected in
'ProductID'.
USERELATIONSHIP(Sal
es[Date],
Calendar[Date])
USERELATIONSHIP
Function Example
This activates a
specific relationship.
CROSSFILTER Function Example