title: Is it possible to join tables based on different columns, dependent on if a value is present?
body: <p>I am trying to build row level security on a dashboard.
  I have 2 helper tables described below - one that shows user access and one that shows branches</p>
  <h2>User Access</h2>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>User</th>
  <th>Branch</th>
  <th>Region</th>
  <th>Country</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>User A</td>
  <td>MEL</td>
  <td>All</td>
  <td>All</td>
  </tr>
  <tr>
  <td>User A</td>
  <td>All</td>
  <td>SP</td>
  <td>All</td>
  </tr>
  <tr>
  <td>User B</td>
  <td>All</td>
  <td>IP</td>
  <td>All</td>
  </tr>
  <tr>
  <td>User B</td>
  <td>All</td>
  <td>SP</td>
  <td>All</td>
  </tr>
  <tr>
  <td>User C</td>
  <td>All</td>
  <td>All</td>
  <td>NZ</td>
  </tr>
  </tbody>
  </table>
  </div><h2>Branch</h2>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>Branch</th>
  <th>Region</th>
  <th>Country</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>MEL</td>
  <td>SP</td>
  <td>AU</td>
  </tr>
  <tr>
  <td>SYD</td>
  <td>SP</td>
  <td>AU</td>
  </tr>
  <tr>
  <td>AKL</td>
  <td>SP</td>
  <td>NZ</td>
  </tr>
  <tr>
  <td>HAN</td>
  <td>IP</td>
  <td>VN</td>
  </tr>
  <tr>
  <td>MNL</td>
  <td>IP</td>
  <td>PH</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>The RLS would take into consideration any of the columns (Branch, Region, Country) and filter the fact table based on the associated branch. eg:</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>User</th>
  <th>Branch</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>User A</td>
  <td>MEL</td>
  </tr>
  <tr>
  <td>User A</td>
  <td>SYD</td>
  </tr>
  <tr>
  <td>User A</td>
  <td>AKL</td>
  </tr>
  <tr>
  <td>User B</td>
  <td>HAN</td>
  </tr>
  <tr>
  <td>User B</td>
  <td>MNL</td>
  </tr>
  <tr>
  <td>User B</td>
  <td>AKL</td>
  </tr>
  <tr>
  <td>User B</td>
  <td>MEL</td>
  </tr>
  <tr>
  <td>User B</td>
  <td>SYD</td>
  </tr>
  <tr>
  <td>User C</td>
  <td>AKL</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>I have tried joining the tables, but as there are three possible joins, I could not get this to work, let alone show incorrect results.</p>
  <p>I also tried creating another table with the following DAX, but the results were not correct:</p>
  <pre><code>RLS = 
      COUNTROWS(
          GENERATE(
              'User Access',
              FILTER(
                  'Branch',
                  'User Access'[BRANCH] = 'Branch'[BRANCH] ||
                  'User Access'[COUNTRY] = 'Branch'[COUNTRY] ||
                  'User Access'[REGION] = 'Branch'[REGION]
              )
          )
      )
  </code></pre>