1.

What are Data Types in DAX?

Answer»

To create DAX FORMULAS, one should understand Context. Context is nothing but the result of the DAX formula will change based on Current Cell or Row for any related data.

Types of Context:

  • Row Context (Multiple Row Context):

Current Row or a single line of record is called a Row context.
E.g. Table “Sales”

Product IDProduct NamePriceQuantity
1A31
2B22
3C13

Here we MUST create Measure to derive the Total Sales i.e. Row by Row.

Hence we have to use SUMX() Function to calculate the Price X Quantity.

In SUMX ‘X’ mean Iterate. Row by Row data calculate/Evaluation

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

First, go to Row 1 =Take Product of Price and Quantity as 3 * 1

Move to next Row 2= from row 1 result ‘3’, sum up with Product of Price and Quantity as 2*2 And so, on till it reaches the end of the table.

  • Working in backend:

Row 1 = 3*1

Row 2= 3+(2*2)

Row 3 = 7+(1*3)

Total Sales = 10

Example Snippet for better understanding:

  • Query Context:

As we all know that Context will change based on Current Cell or Row for any related data.

For example, consider Snippet below, you pull the Net Sales into Table or Matrix visual (Basically Tabular model), then according to Row and columns are chosen from Dimension table, Slicers selected or any kind of report filters applied Data will appear.

Filter context is simply is applying a filter on evaluation while creating Measure.

E.g. Below used Calculate() function which has the capability to change the context by applying filters.

Basically its evaluation Profit for Same Period Last Year using SamePeriodLastYear() function in Calculate.



Discussion

No Comment Found