0% found this document useful (0 votes)
6 views6 pages

Dax Functions Formatted Guide

The document serves as a study guide for understanding DAX functions in Power BI, focusing on helper functions, return types, and common nesting patterns. It categorizes functions based on their return types—logical values, tables, date tables, and scalar values—and provides examples of how these functions can be used in conjunction with others. Key insights include the importance of knowing what a function returns to effectively nest them in calculations.

Uploaded by

Kanishk Bhagat
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)
6 views6 pages

Dax Functions Formatted Guide

The document serves as a study guide for understanding DAX functions in Power BI, focusing on helper functions, return types, and common nesting patterns. It categorizes functions based on their return types—logical values, tables, date tables, and scalar values—and provides examples of how these functions can be used in conjunction with others. Key insights include the importance of knowing what a function returns to effectively nest them in calculations.

Uploaded by

Kanishk Bhagat
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

DAX Functions That Need Other Functions

A study guide for understanding helper functions, return types, and the most common nesting patterns in Power BI DAX.

1. Core Idea
A lot of DAX functions are not complete formulas by themselves. They return a value that another function must consume: a logical value, a table, a date table, or a scalar value.

Return type What it means Typical functions that consume it

Logical value TRUE or FALSE IF, FILTER, CALCULATE

Table A set of rows/columns CALCULATE, SUMX, COUNTROWS, AVERAGEX

Date table A table of dates CALCULATE with time intelligence

Scalar value A single number/text/date Can stand alone or be nested

2. Logical Functions
These return TRUE/FALSE and are usually used inside IF, FILTER, or CALCULATE.

Function Return type Usually used with Example

AND() Logical IF / FILTER AND(Sales[Amount] > 1000, Sales[Profit] > 100)

OR() Logical IF / FILTER OR(Sales[Region] = "Nagpur", Sales[Region] = "Mumbai")

NOT() Logical IF / FILTER NOT(Sales[Amount] > 500)

High Profit Sales =


IF(
AND(Sales[Amount] > 1000, Sales[Profit] > 100),
"Good",
"Bad"
)

Region Label =
IF(
OR(Sales[Region] = "Nagpur", Sales[Region] = "Mumbai"),
"Maharashtra",
"Other"
)

Sale Status =
IF(

Page 1
NOT(Sales[Amount] > 500),
"Low Sale",
"Good Sale"
)

3. FILTER()
FILTER() returns a table, not a final answer. It usually sits inside CALCULATE, SUMX, or COUNTROWS.

Use case Pattern

With CALCULATE CALCULATE(SUM(Sales[Amount]), FILTER(Sales, Sales[Amount] > 1000))

With COUNTROWS COUNTROWS(FILTER(Sales, Sales[Amount] > 1000))

High Sales =
CALCULATE(
SUM(Sales[Amount]),
FILTER(Sales, Sales[Amount] > 1000)
)

Orders Above 1000 =


COUNTROWS(
FILTER(Sales, Sales[Amount] > 1000)
)

4. ALL()
ALL() removes filters and is usually used inside CALCULATE.

Function Return type Used with Example

ALL() Table CALCULATE ALL(Sales)

Total Sales Ignore Filters =


CALCULATE(
SUM(Sales[Amount]),
ALL(Sales)
)

5. VALUES()
VALUES() returns a one-column table of unique values.

Page 2
Function Return type Usually used with Example

VALUES() Table COUNTROWS / CONCATENATEX VALUES(Customer[City])

Unique Cities =
COUNTROWS(
VALUES(Customer[City])
)

Cities List =
CONCATENATEX(
VALUES(Customer[City]),
Customer[City],
", "
)

6. Time Intelligence Functions


These return date tables and are usually wrapped in CALCULATE.

Function Return type Used with Example

DATESYTD() Date table CALCULATE DATESYTD(Date[Date])

SAMEPERIODLASTYEAR() Date table CALCULATE SAMEPERIODLASTYEAR(Date[Date])

YTD Sales =
CALCULATE(
SUM(Sales[Amount]),
DATESYTD(Date[Date])
)

Last Year Sales =


CALCULATE(
SUM(Sales[Amount]),
SAMEPERIODLASTYEAR(Date[Date])
)

7. RELATEDTABLE()
RELATEDTABLE() returns a table and is usually combined with aggregators.

Function Return type Usually used with Example

RELATEDTABLE() Table COUNTROWS / SUMX RELATEDTABLE(Sales)

Page 3
Customer Order Count =
COUNTROWS(
RELATEDTABLE(Sales)
)

8. SUMMARIZE()
SUMMARIZE() returns a table of grouped rows.

Function Return type Usually used with Example

SUMMARIZE() Table COUNTROWS / ADDCOLUMNS SUMMARIZE(Sales, Sales[Region])

Region Count =
COUNTROWS(
SUMMARIZE(Sales, Sales[Region])
)

9. Iterator Functions
Iterator functions need both a table and an expression.

Function Input needed What it does Example

SUMX() Table + expression Row-by-row sum SUMX(Sales, Sales[Quantity] * Sales[Price])

AVERAGEX() Table + expression Row-by-row average AVERAGEX(Sales, Sales[Profit])

COUNTX() Table + expression Counts row expressions COUNTX(Sales, Sales[Amount])

RANKX() Table + expression Ranks values RANKX(ALL(Product), [Total Sales])

Total Revenue =
SUMX(
Sales,
Sales[Quantity] * Sales[Price]
)

Product Rank =
RANKX(
ALL(Product),
[Total Sales]
)

Page 4
10. CALCULATE()
CALCULATE() is not complete without an expression and optional filters.

Function Needs Example

CALCULATE() Expression + optional filters CALCULATE(SUM(Sales[Amount]), Sales[Region] = "West")

Total Sales West =


CALCULATE(
SUM(Sales[Amount]),
Sales[Region] = "West"
)

11. Big DAX Insight


The confusion usually comes from not knowing what a function returns. Once you classify a function as scalar, logical, or table, you immediately know what it can be nested inside.

Return type Examples

Scalar value SUM, MAX, DIVIDE

Logical value AND, OR, NOT

Table FILTER, VALUES, DATESYTD, ALL

12. Easy Mental Model


If a function returns TRUE/FALSE, use it inside IF, FILTER, or CALCULATE. If it returns a table, use it inside CALCULATE, SUMX, COUNTROWS, or AVERAGEX. If it returns a
scalar value, it can usually stand alone.

13. Most Common Nesting Patterns


Pattern Shape

Pattern 1 CALCULATE( aggregation, FILTER(...) )

Pattern 2 IF( logical_test, result1, result2 )

Pattern 3 COUNTROWS( FILTER(...) )

Pattern 4 SUMX( table, expression )

CALCULATE(
aggregation,

Page 5
FILTER(...)
)

IF(
logical_test,
result1,
result2
)

COUNTROWS(
FILTER(...)
)

SUMX(
table,
expression
)

14. How to Think About DAX


Do not memorize formulas first. First ask: What does this function return? Then ask: Which functions can accept that return type? That is the fastest path to getting
comfortable with DAX.

Page 6

You might also like