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

Dax Formulas

This document provides a summary of many common and useful DAX functions organized into categories like math, filtering, logical operations, dates, text manipulation, and more. It includes brief descriptions of functions like SUM, FILTER, IF, DATE, CONCATENATE, and others to perform calculations, filter context, conditional logic, date math, and text formatting in Power BI. Examples are given to illustrate how each function can be used to summarize and analyze data.

Uploaded by

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

Dax Formulas

This document provides a summary of many common and useful DAX functions organized into categories like math, filtering, logical operations, dates, text manipulation, and more. It includes brief descriptions of functions like SUM, FILTER, IF, DATE, CONCATENATE, and others to perform calculations, filter context, conditional logic, date math, and text formatting in Power BI. Examples are given to illustrate how each function can be used to summarize and analyze data.

Uploaded by

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

https://absentdata.

com/power-bi/10-dax-most-useful-power-bi-functions/
https://learn.microsoft.com/en-us/dax/format-function-dax
https://hevodata.com/learn/dax-functions/
https://data-flair.training/blogs/power-bi-dax-basics/
https://www.datacamp.com/cheat-sheet/dax-cheat-sheet

https://community.powerbi.com/t5/Power-Query/assign-multiple-values-to-single-parameter/td-
p/1241008

https://www.enjoysharepoint.com/power-bi-measure-based-on-slicer/

MEASURES
Approv. Labour Cost in USD_ = FORMAT(SUM('Maintenance and Repair'[Approved Labour Cost in
USD]),"#,##0")

Diffs = SWITCH(TRUE(),
[% EDI Approval]>0,
UNICHAR(9660), BLANK())

EDI Approval USD = CALCULATE(SUM('Maintenance and Repair'[Approved Cost in USD]), 'Maintenance


and Repair'[Approved By] = "Edi")

% EDI Approval = CALCULATE([EDI Approval USD]/[Total Approved Cost in USD])

https://www.datacamp.com/cheat-sheet/dax-cheat-sheet

Maths & Statistical Functions


 SUM(<column>) Adds all the numbers in a column.
 SUMX(<table>, <expression>) Returns the sum of an expression evaluated
for each row in a table.
 AVERAGE(<column>) Returns the average (arithmetic mean) of all the
numbers in a column.
 AVERAGEX(<table>, <expression>) Calculatesthe average (arithmetic
mean) of a set of expressions evaluated over a table.
 MEDIAN(<column>) Returns the median of a column.
 MEDIANX(<table>, <expression>) Calculates the median of a set of
expressions evaluated over a table.
 GEOMEAN(<column>) Calculates the geometric mean of a column.
 GEOMEANX(<table>, <expression>) Calculates the geometric mean of a set
of expressions evaluated over a table.
 COUNT(<column>) Returns the number of cells in a column that contains
non-blank values.
 COUNTX(<table>, <expression>) Counts the number of rows from an
expression that evaluates to a non-blank value.
 DIVIDE(<numerator>, <denominator> [,<alternateresult>]) Performs
division and returns alternate result or BLANK() on division by 0.
 MIN(<column>) Returns a minimum value of a column.
 MAX(<column>) Returns a maximum value of a column.
 COUNTROWS([<table>]) Counts the number of rows in a table.
 DISTINCTCOUNT(<column>) Counts the number of distinct values in a
column.
 RANKX(<table>, <expression>[, <value>[, <order>[, <ties>]]]) Returns
the ranking of a number in a list of numbers for each row in the table
argument.

Filter Functions
 FILTER(<table>, <filter>) Returns a table that is a subset of another
table or expression.
 CALCULATE(<expression>[, <filter1> [, <filter2> [, …]]]) Evaluates an
expression in a filter context.
 HASONEVALUE(<columnName>) Returns TRUE when
the context for
columnName has been filtered down to one distinct value only.
Otherwise, it is FALSE.
 ALLNOBLANKROW(<table> | <column>[, <column>[, <column>[,…]]]) Returns a
table that is a subset of another table or expression.
 ALL([<table> | <column>[, <column>[, <column>[,…]]]]) Returns all the
rows in a table, or all the values in a column, ignoring any filters that
might have been applied.
 ALLEXCEPT(<table>, <column>[, <column>[,..]]) Returns all the rows in a
table except for those rows that are affected by the specified column
filters.
 REMOVEFILTERS([<table> | <column>][, <column>[, <column>[,…]]]]) Clear
all filters from designated tables or columns.

Logical Functions
 IF(<logical_test>, <value_if_true>[, <value_if_false>]) Checks a
condition, and returns a certain value depending on whether it is true or
false.
 AND(<logical 1>, <logical 2>) Checks whether both arguments are TRUE,
and returns TRUE if both arguments are TRUE. Otherwise, it returns FALSE.
 OR(<logical 1>, <logical 2>) Checks whether one of the arguments
is TRUE to return TRUE. The function returns FALSE if both arguments
are FALSE.
 NOT(<logical>) Changes TRUE to FALSE and vice versa.
 SWITCH(<expression>, <value>, <result>[, <value>, <result>]…[,
<else>]) Evaluates an expression against a list of values and returns
one of possible results
 IFERROR(<value>, <value_if_error>) Returns value_if_error if the first
expression is an error and the value of the expression itself otherwise.

Date & Time Functions


 CALENDAR(<start_date>, <end_date>) Returnsa table with a single column
named "Date" that contains a contiguous set of dates.
 DATE(<year>, <month>, <day>) Returns the specified date in datetime
format.
 DATEDIFF(<date_1>, <date_2>, <interval>) Returns the number of units
between two dates as defined in <interval>.
 DATEVALUE(<date_text>) Converts a date in text to a date in datetime
format.
 DAY(<date>) Returns a number from 1 to 31 representing the day of the
month.
 WEEKNUM(<date>) Returns weeknumber in the year.
 MONTH(<date>) Returns a number from 1 to 12 representing a month.
 QUARTER(<date>) Returns a number from 1 to 4 representing a quarter.

Time Intelligence Functions


 DATEADD(<dates>, <number_of_intervals>, <interval>) Moves a date by a
specific interval.
 DATESBETWEEN(<dates>, <date_1>, <date_2>) Returns the dates between
specified dates.
 TOTALYTD(<expression>, <dates>[, <filter>][,
<year_end_date>]) Evaluates the year-to-date value of the expression in
the current context.
 SAMEPERIODLASTYEAR(<dates>) Returns a table that contains a column of
dates shifted one year back in time.
 STARTOFMONTH(<dates>) // ENDOFMONTH(<dates>) Returns the start // end of
the month.
 STARTOFQUARTER(<dates>) // ENDOFQUARTER(<dates>) Returns the start // end
of the quarter.
 STARTOFYEAR(<dates>) // ENDOFYEAR(<dates>) Returns the start // end of the
quarter.

Relationship Functions
 CROSSFILTER(<left_column>, <right_column>, <crossfiltertype>) Specifies
the cross-filtering direction to be used in a calculation.
 RELATED(<column>) Returns a related value from another table.

Table Manipulation Functions


 SUMMARIZE(<table>, <groupBy_columnName>[, <groupBy_columnName>]…[,
<name>, <expression>]…) Returns a summary table for the requested
totals over a set of groups.
 DISTINCT(<table>) Returns a table by removing duplicate rows from
another table or expression.
 ADDCOLUMNS(<table>, <name>, <expression>[, <name>, <expression>]…) Adds
calculated columns to the given table or table expression.
 SELECTCOLUMNS(<table>, <name>, <expression>[, <name>, <expression>]
…) Selects calculated columns from the given table or table expression.
 GROUPBY(<table> [, <groupBy_columnName>[, [<column_name>]
[<expression>]]…) Create a summary of the input table grouped by
specific columns.
 INTERSECT(<left_table>, <right_table>) Returns the rows of the left-side
table that appear in the right-side table.
 NATURALINNERJOIN(<left_table>, <right_table>) Joins two tables using an
inner join.
 NATURALLEFTOUTERJOIN(<left_table>, <right_table>) Joins two tables using
a left outer join.
 UNION(<table>, <table>[, <table> [,…]]) Returns the union of tables with
matching columns.

Text Functions
 EXACT(<text_1>, <text_2>) Checks if two strings are identical (EXACT() is
case sensitive).
 FIND(<text_tofind>, <in_text>) Returns the starting position a text within
another text (FIND() is case sensitive).
 FORMAT(<value>, <format>) Converts a value to a text in the specified
number format.
 LEFT(<text>, <num_chars>) Returns the number of characters from the
start of a string.
 RIGHT(<text>, <num_chars>) Returns the number of characters from the
end of a string.
 LEN(<text>) Returns the number of characters in a string of text.
 LOWER(<text>) Converts all letters in a string to lowercase.
 UPPER(<text>) Converts all letters in a string to uppercase.
 TRIM(<text>) Remove all spaces from a text string.
 CONCATENATE(<text_1>, <text_2>) Joins two strings together into one
string.
 SUBSTITUTE(<text>, <old_text>, <new_text>, <instance_num>) Replaces
existing text with new text in a string.
 REPLACE(<old_text>, <start_posotion>, <num_chars>,
<new_text>) Replaces part of a string with a new string.

Information Functions
 COLUMNSTATISTICS() Returns statistics regarding every column in every
table. This function has no arguments.
 NAMEOF(<value>) Returns the column or measure name of a value.
 ISBLANK(<value>) // ISERROR(<value>) Returns whether the value is blank //
an error.
 ISLOGICAL(<value>) Checks whether a value is logical or not.
 ISNUMBER(<value>) Checks whether a value is a number or not.
 ISFILTERED(<table> | <column>) Returns true when there are direct filters
on a column.
 ISCROSSFILTERED(<table> | <column>) Returns true when there are
crossfilters on a column.
 USERPRINCIPALNAME() Returnsthe user principal name or email address.
This function has no arguments.

DAX Statements
 VAR(<name> = <expression>) Stores the result of an expression as a
named variable. To return the variable, use RETURN after the variable
is defined.
 COLUMN(<table>[<column>] = <expression>) Stores the result of an
expression as a column in a table.
 ORDER BY(<table>[<column>]) Definesthe sort order of a column. Every
column can be sorted in ascending (ASC) or descending (DESC) way.

DAX Operators

Comparison operators Meaning

= Equal to

= = Strict equal to 

> Great than

< Smaller than

> = Greater than or equal to

= < Smaller than or equal to

< > Not equal to 

Text
Meaning Example
operator

&
Concatenates text Concatenates text values | [City]&",
values "&[State]

Logical
Meaning Example
operator
&& AND condition ([City] = "Bru") && ([Return] = "Yes"))

|| OR condition ([City] = "Bru") || ([Return] = "Yes"))

OR condition for each Product[Color] IN {"Red", "Blue",


IN {} 
row "Gold"}

https://hevodata.com/learn/dax-functions/

https://data-flair.training/blogs/power-bi-dax-basics/

Types of DAX functions


1. Date and Time Functions
The date time functions carry out calculations on the date and time values.
The data type of these values is always datetime data type.

 CALENDAR
 CALENDARAUTO
 DATE
 DATEDIFF
 DATEVALUE
 DAY
 EOMONTH
 HOUR
 MINUTE
 MONTH
 NOW
 SECOND
 TIME
 TIMEVALUE
 TODAY
 WEEKDAY
 WEEKNUM
 YEAR
 YEARFRAC
2. Time Intelligence Functions
The time-intelligence functions are used to evaluate values over a fixed period
such as days, weeks, months, quarter, years, etc. You can specify a time period
using these functions and compare two scenarios in your report.
 CLOSINGBALANCEMONTH
 CLOSINGBALANCEQUARTER
 CLOSINGBALANCEYEAR
 DATEADD
 DATESBETWEEN
 DATESINPERIOD
 DATESMTD
 DATESQTD
 DATESYTD
 ENDOFMONTH
 ENDOFQUARTER
 ENDOFYEAR
 FIRSTDATE
 FIRSTNONBLANK
 LASTDATE
 NEXTQUARTER
 LASTNONBLANK
 NEXTDAY
 NEXTMONTH
3. Information Functions
The information functions are used to provide certain information on the data
values contained in rows and columns. It evaluates the given condition in a
function for the value given and return TRUE or FALSE. For instance, the
function ISERROR will return TRUE if the value evaluated contains an error.

 CONTAINS
 CUSTOMDATA
 IN Operator / CONTAINSROW function
 ISBLANK
 ISERROR
 ISEVEN
 ISINSCOPE
 ISLOGICAL
 ISNONTEXT
 ISNUMBER
 ISODD
 ISONORAFTER
 ISTEXT
 LOOKUPVALUE
 USERNAME
4. Logical Functions
The logical functions are used to evaluate an expression or argument logically
and return TRUE or FALSE if the condition is met or not.

 AND
 FALSE
 IF
 IFERROR
 IN
 NOT
 OR
 SWITCH
 TRUE
5. Mathematical and Trigonometric Functions
The mathematical and trig functions are used to perform all sorts of
mathematical functions on the referred values. Given below, is a list of all the
available math and trig DAX functions in Power BI.

 ABS
 ACOS
 ACOSH
 ASIN
 ASINH
 ATAN
 ATANH
 CEILING
 COMBIN
 COMBINA
 COS
 COSH
 CURRENCY
 DEGREES
 DIVIDE
 EVEN
 EXP
 FACT
 FLOOR
6. Statistical Functions
These functions carry out statistical and aggregation functions on data values
in a DAX expression in Power BI. The list of available statistical functions is
given below.

 ADDCOLUMNS
 APPROXIMATEDISTINCTCOUNT
 AVERAGE
 AVERAGEA
 AVERAGEX
 BETA.DIST
 BETA.INV
 CHISQ.INV
 CHISQ.INV.RT
 CONFIDENCE.NORM
 CONFIDENCE.T
 COUNT
 COUNTA
 COUNTAX
 COUNTBLANK
 COUNTROWS
 COUNTX
 CROSSJOIN
 DISTINCTCOUNT
 EXPON.DIST
 GENERATE
 GENERATEALL
 GEOMEAN
 GEOMEANX
 MAX
 MAXA
 MAXX
 MEDIAN
 MEDIANX
 MIN
 MINA
 MINX
7. Text Functions
The text functions in Power BI are very similar to the string functions of Excel.
These functions evaluate string values.

 BLANK
 CODE
 COMBINEVALUES
 CONCATENATE
 CONCATENATEX
 EXACT
 FIND
 FIXED
 FORMAT
 LEFT
 LEN
 LOWER
 MID
 REPLACE
 REPT
 RIGHT
 SEARCH
 SUBSTITUTE
 TRIM
 UNICHAR
 UPPER
 VALUE
8. Parent-Child functions
The parent and child functions are used for data values that are a part of a
parent-child hierarchy.

 PATH
 PATHCONTAINS
 PATHITEM
 PATHITEMREVERSE
 PATHLENGTH
9. Other functions
There a bunch of functions that do not fit in any particular category. These are
also very useful functions.

 DATATABLE
 ERROR
 EXCEPT
 GENERATESERIES
 GROUPBY
 INTERSECT
 ISEMPTY
 ISSELECTEDMEASURE
 NATURALINNERJOIN
 NATURALLEFTOUTERJOIN
 SELECTEDSMEASURE
 SELECTEDMEASUREFORMATSTRING
 SELECTEDSMEASURENAME
 SUMMARIZECOLUMNS
 Table Constructor
 TREATAS
 UNION
 VAR
10. Table functions
The table functions in DAX formulas for Power BI are used to apply
operations and conditions on entire tables. The output of table functions is
used as inputs in other expressions or arguments in a DAX formula. The
results of these functions retain the relationships between columns of that
table.
 FILTER
 ALL
 VALUES
 DISTINCT
 RELATEDTABLE
Let’s explore How to Create Power BI Dashboard
DAX Context
The concept of DAX context is essential in gaining a complete understanding
of DAX language and how it works in Power BI. There are two types of DAX
contexts; Row context and Filter context.

 Row context: Row context means taking into account a specific row


that has been filtered in a DAX expression. The row context focuses
on the operation of the formula on the current row. This type of
context is most often applied to the measure rows.
 Filter context: The filter context takes focusing on values one step
ahead. In row context, we were filtering out and applying operations
on specific rows. But in filter context, the expression applies a filter
to focus on specific values within a row. Thus, the filter context is
applied in addition to the row context to narrow down the scope of
calculation to specific values. Filter context is applied when we use
functions like CALCULATE, FILTER, RELATED, ALL, etc.

https://absentdata.com/power-bi/10-dax-most-useful-power-bi-functions/
https://learn.microsoft.com/en-us/dax/format-function-dax

You might also like