Use DAX iterator functions in Power BI Desktop models

Data Analysis Expressions (DAX) include a set of functions known as iterator functions. Iterator functions enumerate all rows of a given table and evaluate a given expression for each row. They provide you with flexibility and control over how your model calculations will summarize data.

Some DAX Functions are

Complex summarization
1. SUMX

e.g. : 1. Revenue =SUMX(Sales, Sales[Sales Amount])

2. Revenue =SUMX(Sales, Sales[Order Quantity] * Sales[Unit Price] * (1 - Sales[Unit Price Discount Pct.]))

3. Discount =SUMX(Sales, Sales[Order Quantity]*(RELATED('Product'[List Price]) - Sales[Unit Price]))

2. AVERAGEX

e.g :1. Revenue Avg =AVERAGEX(Sales, Sales[Order Quantity] * Sales[Unit Price] * (1 - Sales[Unit Price Discount Pct.]))

2. Revenue Avg Order =AVERAGEX(VALUES('Sales Order'[Sales Order]),[Revenue])

3. RANKX

The RANKX DAX function is a special iterator function you can use to calculate ranks. Its syntax is as follows:

RANKX(<table>, <expression>[, <value>[, <order>[, <ties>]]])

e.g 1. Product Quantity Rank =RANKX(ALL('Product'[Product]),[Quantity])

2. Product Quantity Rank =RANKX(ALL('Product'[Product]),[Quantity],,,DENSE)

3. Product Quantity Rank =IF(HASONEVALUE('Product'[Product]),RANKX(ALL('Product'[Product]),[Quantity],,,DENSE))


Conclusion:

Get handson experience by using SUMX, AVERAGEX, RANKX DAX functions.

Comments

Post a Comment

Popular posts from this blog

Different charts in Power BI

Modify DAX filter context in Power BI Desktop models