Forum Discussion
mmann02
7 years agoNew Member
DAX Studio and Filter Context
Hello, I've read lots of documentation regarding filter context, but to make it concrete my desire is to be able to play around with the various filter and table functions to see what happens. ...
- 7 years ago
Hey,
it's possible to recreate the filter context in DAX Studio, but before you start trying different things it's necessary understand the following:
- each slicer selection is translated into a table, this table will be used tablefilter, as a side note, this explains why every filter in DAX is a table.
CALCULATE( SUM('fact sale'[quantity]) ,'dimension city'[sales territory] = "Plains" )Is basically this
calculate( sum('fact sale'[quantity] ,filter(all('dimension city'[sales territory]), [sales territory] = "Plains") )You have to note that filter returns a table, even if this table just has one column.
this is a DAX query traced by DAX Studio:
DEFINE VAR __DS0FilterTable = TREATAS({"Plains"}, 'Dimension City'[Sales Territory]) EVALUATE SUMMARIZECOLUMNS( 'Dimension City'[State Province], __DS0FilterTable, "SumQuantity", CALCULATE(SUM('Fact Sale'[Quantity])) )
Hopefully this provides some insights that you might missing.Regards,
Tom
- each slicer selection is translated into a table, this table will be used tablefilter, as a side note, this explains why every filter in DAX is a table.
TomMartens
Super User
7 years agoHey,
it's possible to recreate the filter context in DAX Studio, but before you start trying different things it's necessary understand the following:
- each slicer selection is translated into a table, this table will be used tablefilter, as a side note, this explains why every filter in DAX is a table.
CALCULATE( SUM('fact sale'[quantity]) ,'dimension city'[sales territory] = "Plains" )Is basically this
calculate( sum('fact sale'[quantity] ,filter(all('dimension city'[sales territory]), [sales territory] = "Plains") )You have to note that filter returns a table, even if this table just has one column.
this is a DAX query traced by DAX Studio:
DEFINE VAR __DS0FilterTable =
TREATAS({"Plains"}, 'Dimension City'[Sales Territory])
EVALUATE
SUMMARIZECOLUMNS(
'Dimension City'[State Province],
__DS0FilterTable,
"SumQuantity", CALCULATE(SUM('Fact Sale'[Quantity]))
)
Hopefully this provides some insights that you might missing.
Regards,
Tom
mmann02
7 years agoNew Member
That is precisely the insight I was missing. Lots of things are already considerably more clear. Thank you!