title: Optional FILTER in CALCULATE in DAX
body: <p>Similarly to the <a href="https://www.daxpatterns.com/basket-analysis/" rel="nofollow noreferrer">Basket Analysis</a> DAX pattern model, I have 1 fact for Sales, 1 dimension for Product and an extra dimension for Filter Product.</p>
  
  <p>I want to use the Filter Product dimension to exclude products chosen by the user. I made it work with this DAX formula:</p>
  
  <pre><code>Sales =
  CALCULATE (
      SUM ( Sales['Sales'] ),
      FILTER (
          Product,
          NOT ( 'Product'['ProductName'] IN VALUES ( 'FilterProduct'['ProductName'] ) )
      )
  )
  </code></pre>
  
  <p>This works as long as the user has already chosen a Product to exclude on FilterProduct slicer. But if nothing has been selected, the calculation will show blank, rather than just show everything. I wonder if there's a way to handle this gracefully. An idea I had was to create a variable and see if FilterProduct ISFILTERED(). If so, copy&amp;paste the above with the FILTER() on  SWITCH statement, if not, just skip the FILTER(). But this isn't great, because it duplicates code, and if I was to add another optional filter (e.g. SalesRegion), I'd had to pre-calculate all the combinations (e.g. SalesRegion &amp; Product, just SalesRegion, just Product, none).</p>