Tags

, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,


DAX with Tabular Model Series – What is a Context in DAX?

Context basically used to perform dynamic analysis, in which the results of a formula can change to reflect the current row selection and also any related data.

Understanding context and using context effectively are critical for building high-performing, dynamic analyses, and for troubleshooting problems in formulas.

Context is also called as Evaluation Context

There are following types of context-

  • Row context
  • Query context
  • Filter context

Filter context is the set of values allowed in each column, based on filter constraints that were applied to the row or that are defined by filter expressions within the formula. In simple terms you can consider filter context as a set of conditions in a WHERE clause of a SQL SELECT statement.

For example, check out a sample SQL statement and Equivalent DAX

SQL

--

SELECT ColorType
FROM Colors
WHERE ColorType <> -1

--

DAX

--

EVALUATE
(
	FILTER
	(
		VALUES('[Colors]'[ColorType]),
		ColorType <> -1
	)
)

--

Pawan Kumar Khowak - DAX with Tabular Model- II(Context)

Check out the picture above – DAX

Evaluate is the keyword from where we should start our query. Values clause is used to return distinct column values. It will simply discard the duplicate values and filter used in this query is used as a where clause used to filter out rows where ColorType <> -1. I will explain Row context and query context in the upcoming posts !

Summary

This is the small information about Context in DAX. I will some posts about how context works and row & query context.

That’s all folks; I hope you’ve enjoyed learning about Context in DAX, and I’ll see you soon with more “DAX” articles.

Thanks!

Pawan Kumar Khowal

MSBISKills.com

Advertisements