title: How to Filter table and Limit it to 1 TOP row with Dax
body: <p>I'm new to Power BI and Dax queries.
  I have 2 tables added with 1:* relation. What I'm trying to do is to filter the second table by a foreign key and specific Key.</p>
  Example:
  <pre><code>###Table1:###
  ID | RunID | ...[Other columns]
  
  ###Table2:###
  ID | RunID | Key | Value | State
  </code></pre>
  <p>So what I'm trying to do in Power BI using Dax query is to get value for a key. (It's possible to have duplicated Key-Value pairs but I can take a top one)</p>
  <pre><code>NEWCOLUMN =
  VAR tmp =
      FILTER (
          Table2,
          AND ( Table2[RunID] = Table1[RunID], Table2[Key] = &quot;KEY_I_NEED&quot; )
      )
  VAR tmp2 =
      CALCULATE ( VALUES ( Table2[Value] ), TOPN ( 1, tmp ) )
  RETURN
      tmp2
  </code></pre>
  <p>Right now I'm getting the error:</p>
  <blockquote>
  <p>&quot;The expression refers to multiple columns. Multiple columns cannot be
  converted to a scalar value.&quot;</p>
  </blockquote>
  <p>and couldn't get it to work the way I need.</p>