title: DAX Measure with different granularities
body: <p>I'm looking for help with how to write a specific DAX measure. Here is a simplified version of my data and model:</p>
  
  <p><strong>Tables:</strong>
  <a href="https://i.stack.imgur.com/OPp37.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OPp37.png" alt="Data"></a></p>
  
  <p><strong>Model:</strong></p>
  
  <p><a href="https://i.stack.imgur.com/10SVj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/10SVj.png" alt="Model"></a></p>
  
  <p><strong>Measures:</strong></p>
  
  <pre><code>Total Amt:=SUM(Amounts[Amt])
  Total Pos Amt:=SUMX(Amounts, IF([Amt]&lt;0,0,[Amt]))
  Total Amt All:=CALCULATE([Total Pos Amt],ALL(Ptr))
  Total Amt All 2:=SUMX(Bridge,CALCULATE([Total Pos Amt],ALL(Ptr)))
  Total Amt All 3:=SUMX(VALUES(Bridge[Pri]),CALCULATE([Total Pos Amt],ALL(Ptr)))
  </code></pre>
  
  <p><a href="https://i.stack.imgur.com/Mhb7O.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Mhb7O.png" alt="enter image description here"></a>
  <a href="https://i.stack.imgur.com/sizNC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sizNC.png" alt="enter image description here"></a></p>
  
  <p>As you can see in the first PivotTable (where [Pri] &amp; [Ptr] are row fields), the highlighted cells show values with an issue. The [Total Pos Amt] measure sums up the [Amt] column in the Amounts table by iterating through it and evaluating an expression where negative amounts are treated as zero and positive amounts are kept. At a [Pri] level granularity, I want that same logic to apply (i.e. evaluate the expression at a [Ptr] level). The problem with the [Total Amt All] measure is that on the PivotTable I get a row for [Ptr] Z under [Pri] A which I don't want. Measures [Total Amt All 2] and [Total Amt All 3] solve that issue but the subtotals at a [Pri] level are wrong in [Total Amt All 2] and the grand total is wrong in [Total Amt All 3].</p>
  
  <p>Any help would be greatly appreciated! How can I write a measure that won't show a [Ptr] that is not associated with a [Pri] per the Bridge table, but that also correctly sums up the [Total Pos Amt] measure at a [Pri] level?</p>