title: DAX Difficulty counting rows and assigning a rank
body: <p>I'm trying to select lines from table Cases, count the rows for each Broker in the list, and then get the rank for each Broker.  My code works up to the last step.  I know that because the measure that used the code up to Table 2 is giving me correct results.  But I'm doing something wrong in calculating the rank.  Can you tell me what the problem is?  I tried using ALL(Table3), but that gave me a syntax error (&quot;All needs a table reference, not a table expression.&quot;)</p>
  <p>This is driving me nuts. I've wasted hours trying variations, looking for examples, reading documentation, but there's something here I just don't get.  I finally got the FILTER, SELECTCOLUMNS, SUMMARIZE, and ADDCOLUMNS sequence working correctly.  (Although using SUMMARIZE to add a column is apparently not recommended--but it seems to work OK here.)</p>
  <pre><code>BrkPricedCtRank = 
  VAR Table0 = 
  FILTER ( 'Cases',
      not ISBLANK( [Date To Pricing] )
      &amp;&amp; [Date Initiated] &gt;= date(2021,1,1)
      &amp;&amp; [Date Initiated] &lt;= DATE(2021,12,31)  )
  
  VAR Table1 =
  SELECTCOLUMNS( 
      Table0,  
      &quot;Broker&quot;, [Broker]
      )
  
  VAR Table2 = 
  SUMMARIZE(
      Table1,
      [Broker], 
      &quot;PricedCt&quot;, COUNTROWS( Table1 )  )
  
  --For measure BrkPricedCt. the code continues with these 2 lines.
  --That measure gives me what I want.
  --   RETURN
  --      MINX( Table2, [PricedCt] )
  
  VAR Table3 = 
       ADDCOLUMNS( 
           Table2,
           &quot;Rank&quot;, RANKX( Table2, [PricedCt] )  )
  
  return MINX( Table3, [Rank] )
  </code></pre>
  <p>Here is my output:
  <a href="https://i.stack.imgur.com/e1BE5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/e1BE5.png" alt="enter image description here" /></a></p>