Forum Discussion

mmann02's avatar
mmann02
New Member
7 years ago
Solved

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.  ...
  • TomMartens's avatar
    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