title: Creating a Measure that returns DISTINCT COUNT by Country and Brand in Power BI
body: <p>I have a table like below:</p>
  
  <pre><code>Country, Advertiser, Brand, Spend
  C1,      A1,         B1,    10
  C1,      A1,         B2,    5
  C1,      A2,         B3,    0
  C1,      A2,         B4,    20
  C2,      A1,         B1,    8
  C2,      A1,         B5,    7
  C2,      A2,         B6,    4
  C2,      A2,         B3,    3
  C2,      A2,         B7,    2
  C2,      A3,         B8,    9
  </code></pre>
  
  <p>I'd like to get the <code>DISTINCT COUNT</code> of Brands by Country, which is simply:</p>
  
  <pre><code>C1 =&gt; 4
  C2 =&gt; 6
  </code></pre>
  
  <p>How do I create a measure in <code>Power BI</code> that I can embed in a table or a tree-map? I have already tried this:</p>
  
  <pre><code>Measure = COUNTX(DISTINCT(sourceTable),sourceTable[Brand])
  </code></pre>
  
  <p>which returns total Brand count (not <code>DISTINCT COUNT</code>) per Country... </p>
  
  <p>I have also tried below and it didn't work:</p>
  
  <pre><code>DistinctBrandCount =
      CALCULATE(DISTINCTCOUNT(SampleDataForDashboard[Brand]),
          GROUPBY(SampleDataForDashboard, SampleDataForDashboard[Country]))
  </code></pre>