title: How to JOIN summarized data from two queries into new table in DAX Power BI
body: <p>I have 2 queries: </p>
  
  <p>Premium:</p>
  
  <p><a href="https://i.stack.imgur.com/8MecX.png" rel="noreferrer"><img src="https://i.stack.imgur.com/8MecX.png" alt="enter image description here"></a></p>
  
  <p>and Losses:</p>
  
  <p><a href="https://i.stack.imgur.com/jpZX6.png" rel="noreferrer"><img src="https://i.stack.imgur.com/jpZX6.png" alt="enter image description here"></a></p>
  
  <p>How can I simply summarize data from Premium query and LEFT JOIN it to summarized data in Losses query using DAX?</p>
  
  <p>In SQL it would be like that:</p>
  
  <pre><code>declare @PremiumTable table (PolicyNumber varchar(50), Premium money)
  insert into @PremiumTable values 
                                  ('Pol1', 100),
                                  ('Pol1', 50),
                                  ('Pol2', 300),
                                  ('Pol3', 500),
                                  ('Pol3', 200),
                                  ('Pol4',400)
  
  declare @LossesTable table (PolicyNumber varchar(50), Losses money)
  insert into @LossesTable values ('Pol1',115),
                                  ('Pol1',25),
                                  ('Pol2',0),
                                  ('Pol3',110),
                                  ('Pol3',75)
  
  
  select  p.PolicyNumber, 
          sum(p.Premium) as Premium,
          sum(l.Losses)as Losses  
  from @PremiumTable p 
          LEFT JOIN @LossesTable l on p.PolicyNumber = l.PolicyNumber
  group by p.PolicyNumber
  </code></pre>
  
  <p>Result:</p>
  
  <p><a href="https://i.stack.imgur.com/0Y2L3.png" rel="noreferrer"><img src="https://i.stack.imgur.com/0Y2L3.png" alt="enter image description here"></a></p>
  
  <p>I tried using <code>NATURALLEFTOUTERJOIN</code> but it gives me an error:</p>
  
  <pre><code>*An incompatible join column, (''[PolicyNumber]) was detected. 'NATURALLEFTOUTERJOIN' doesn't support joins by using columns with different data types or lineage.*
  </code></pre>
  
  <hr>
  
  <pre><code>MyTable = 
      VAR Premium = 
              SELECTCOLUMNS(
                  fact_Premium,
                  "PolicyNumber",fact_Premium[PolicyNumber],
                  "Premium", fact_Premium[Premium]
                  )
      VAR Losses = 
                  SELECTCOLUMNS(
                      fact_Losses,
                      "PolicyNumber", fact_Losses[PolicyNumber],
                      "Losses", fact_Losses[PaymentAmount]
                               )
      VAR Result = NATURALLEFTOUTERJOIN(Premium,Losses)
      RETURN Result
  </code></pre>