0% found this document useful (0 votes)
36 views19 pages

DAX Formulas

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 views19 pages

DAX Formulas

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/ 19

DAX Formulas

(Expressions)
Part – 3

Do follow for more Data inSights


Linkedin: KEDAM MAHESH BABU Swipe >>>
Do follow for more Data inSights
Linkedin: KEDAM MAHESH BABU Swipe >>>
1. SUM:
Syntax:
SUM(<column>)
Parameters:
- Adds all the numbers in a column.
Return value:
- A decimal number.
Remarks:
- If you want to filter the values that you are
summing, you can use the SUMX function and specify an
expression to sum over.

Examples:
= SUM(Sales[Amt])
Do follow for more Data inSights
Linkedin: KEDAM MAHESH BABU Swipe >>>
2. SUMX:
Syntax:
SUMX(<table>, <expression>)
Parameters:
- Returns the sum of an expression evaluated for each row in a
table.
Return value:
- A decimal number.
Remarks:
- For more complex examples of SUMX in formulas, see ALL and CALCULATETABLE.
- This function is not supported for use in DirectQuery mode when used in
calculated columns or row-level security (RLS) rules.
Examples:
= SUMX(FILTER(InternetSales,
InternetSales[SalesTerritoryID]=5),[Freight])

Do follow for more Data inSights


Linkedin: KEDAM MAHESH BABU Swipe >>>
3. AVERAGE:
Syntax:
AVERAGE(<column>)
Parameters:
- Returns the average (arithmetic mean) of all the numbers in a
column.
Return value:
- Returns a decimal number that represents the arithmetic
mean of the numbers in the column.
Remarks:
- This function takes the specified column as an argument and finds the
average of the values in that column. If you want to find the average of an
expression that evaluates to a set of numbers, use the AVERAGEX function
instead.
Examples:
= AVERAGE(InternetSales[ExtendedSalesAmount])

Do follow for more Data inSights


Linkedin: KEDAM MAHESH BABU Swipe >>>
4. AVERAGEX:
Syntax:
AVERAGEX(<table>, <expression>)
Parameters:
- Calculates the average (arithmetic mean) of a set of expressions
evaluated over a table.
Return value:
- A decimal number.
Remarks:
- The AVERAGEX function enables you to evaluate expressions for each row of a
table, and then take the resulting set of values and calculate its arithmetic mean.
Therefore, the function takes a table as its first argument, and an expression as the
second argument.
Examples:
= AVERAGEX(InternetSales, InternetSales[Freight]+
InternetSales[TaxAmt])

Do follow for more Data inSights


Linkedin: KEDAM MAHESH BABU Swipe >>>
5. MEDIAN:
Syntax:
MEDIAN(<column>)
Parameters:
- Returns the median of a column.
Return value:
- A decimal number.
Remarks:
- Only the numbers in the column are counted. Blanks are ignored.
Logical values, dates, and text are not supported.
- MEDIAN( Table[Column] ) is equivalent to MEDIANX( Table,
Table[Column] ).
Examples:
= MEDIAN( Customers[Age] )
Do follow for more Data inSights
Linkedin: KEDAM MAHESH BABU Swipe >>>
6. MEDIANX:
Syntax:
MEDIANX(<table>, <expression>)
Parameters:
- Calculates the median of a set of expressions evaluated over a table.
Return value:
- A decimal number.
Remarks:
- The MEDIANX function takes as its first argument a table, or an
expression that returns a table. The second argument is a column that
contains the numbers for which you want to compute the median, or an
expression that evaluates to a column.
Examples:
= MEDIANX( FILTER(Customers, RELATED(
Geography[Country]="USA" ) ), Customers[Age] )
Do follow for more Data inSights
Linkedin: KEDAM MAHESH BABU Swipe >>>
7. GEOMEAN:
Syntax:
GEOMEAN(<column>)
Parameters:
- Calculates the geometric mean of a column.
Return value:
- A decimal number.
Remarks:
- Only the numbers in the column are counted. Blanks, logical values,
and text are ignored.
- GEOMEAN(Table[Column]) is equivalent to GEOMEANX(Table,
Table[Column]).
Examples:
= GEOMEAN(Investment[Return])

Do follow for more Data inSights


Linkedin: KEDAM MAHESH BABU Swipe >>>
8. GEOMEANX:
Syntax:
GEOMEANX(<table>, <expression>)
Parameters:
- Calculates the geometric mean of a set of expressions evaluated over a
table.
Return value:
- A decimal number.
Remarks:
- The GEOMEANX function takes as it first argumrnt a table, or an expression that
returns a table. The second argument is a column that contains the numbers for which
you want to compute the geometric mean, or an expression that evaluates to a column.
- Only the numbers in the column are counted. Blanks, logical values, and text are
ignored.
Examples:
= GEOMEANX(Investments, Investments[ReturnPct] + 1)
Do follow for more Data inSights
Linkedin: KEDAM MAHESH BABU Swipe >>>
9. COUNT:
Syntax:
COUNT(<column>)
Parameters:
- Returns the number of cells in a column that contain non-blank values.
Return value:
- A whole number.
Remarks:
- The only argument allowed to this function is a column. The COUNT
function counts rows that contain the following kinds of values:
- Numbers, Dates, Strings.
- When the function finds no rows to count, it returns a blank.
Examples:
=COUNT([ShipDate])

Do follow for more Data inSights


Linkedin: KEDAM MAHESH BABU Swipe >>>
10. COUNTX:
Syntax:
COUNTX(<table>, <expression>)
Parameters:
- COUNTXCounts the number of rows from an expression that evaluates to a
non-blank value.
Return value:
- An integer.
Remarks:
- The COUNTX function takes two arguments. The first argument must always
be a table, or any expression that returns a table. The second argument is the
column or expression that is searched by COUNTX.
Examples:
1. =COUNTX(Product,[ListPrice])
2. = COUNTX(FILTER(Product,
RELATED(ProductSubcategory[EnglishProductSubcategoryName])=“Caps”),
Product[ListPrice])
Do follow for more Data inSights
Linkedin: KEDAM MAHESH BABU Swipe >>>
11. DIVIDE:
Syntax:
DIVIDE(<numerator>, <denominator> [,<alternateresult>])
Parameters:
- Performs division and returns alternate result or BLANK() on division
by 0.
Return value:
- A decimal number.
Remarks:
- Alternate result on divide by 0 must be a constant.
Examples:
1. = DIVIDE(5, 2) # Output: 2.5
2. = DIVIDE(5, 0) # output: BLANK
3. = DIVIDE(5, 0, 1) # output: 1

Do follow for more Data inSights


Linkedin: KEDAM MAHESH BABU Swipe >>>
12. MIN:
Syntax:
MIN(<column>) (Or) MIN(<expression1>, <expression2>)
Parameters:
- Returns a minimum value of a column.
Return value:
- A smallest value.
Remarks:
- The MIN function takes a column or teo expressions as an argument, and returns the
smallest value. The following types of values in the columns are connected.
- Numbers, Texts, Dates, Blanks.
Examples:
1. = MIN([Resellermargin])
2. = MIN([TransactionDate])
3. = MIN([TotalSales], [TotalPurchases])

Do follow for more Data inSights


Linkedin: KEDAM MAHESH BABU Swipe >>>
13. MAX:
Syntax:
MAX(<column>) (Or) MAX(<expression1>, <expression2>)
Parameters:
- Returns a maximum value of a column.
Return value:
- A largest value.
Remarks:
- When comparing two expressions, blank is treated as 0 when
comparing. That is, Max(1, Blank()) returns 1, and Max(-1, Blank())
returns 0. If both arguments are blank, MAX returns a blank. If either
expression returns a value which is not allowed, Max returns an error.
Examples:
1. = MAX(InternetSales[ExtendedAmount])
2. = MAX([TotalSales], [TotalPurchase])

Do follow for more Data inSights


Linkedin: KEDAM MAHESH BABU Swipe >>>
14. COUNTROWS:
Syntax:
COUNTROWS([<table>])
Parameters:
- Counts the number of rows in a table.
Return value:
- A whole number.
Remarks:
- This function can be used to count the number of rows in a base table,
but more often is used to count the number of rows that result from
filtering a table, or applying context to a table.
Examples:
1. = COUNTROWS(‘Orders’)
2. = COUNTROWS(RELATEDTABLE(ResellerSales))

Do follow for more Data inSights


Linkedin: KEDAM MAHESH BABU Swipe >>>
15. DISTINCTCOUNT :
Syntax:
DISTINCTCOUNT(<column>)
Parameters:
- Counts the number of distinct values in a column.
Return value:
- A number of distinct values in column.
Remarks:
- The only argument allowed to this function is a column. You can use
columns containing any type of data. When the function finds no rows
to count, it returns a BLANK, otherwise it returns the count distinct
values.
Examples:

= DISTINCTCOUNT(ReSellerSales_USD[SalesOrderNumber])

Do follow for more Data inSights


Linkedin: KEDAM MAHESH BABU Swipe >>>
16. RANKX:
Syntax:
RANKX(<table>, <expression>[ , <value>[ , <order> [ ,<ties>]]])
Parameters:
- Returns the ranking of a number in a list of numbers for each row in
the table argument.
Return value:
- A rank number of value among all possible values of expression
evaluated for all rows of table numbers.
Remarks:
- If expression or value evaluates to BLANK it is treated as a 0 (Zero) for
all expressions that result in a number, or as an empty text for all text
expressions.
Examples:
= RANKX(ALL(Products),
SUMX(RELATEDTABLE(InternetSales), [SalesAmount]))

Do follow for more Data inSights


Linkedin: KEDAM MAHESH BABU Swipe >>>
Like the post
Follow me on
For more Data Insights

@ KEDAM MAHESH BABU

You might also like