title: SSAS comparing previous rows data and get the count
body: <p>I have following Scenario in cube</p>
  <div class="s-table-container">
  <table class="s-table">
  <thead>
  <tr>
  <th>ID</th>
  <th>PreID</th>
  <th>Code</th>
  <th>Valid</th>
  </tr>
  </thead>
  <tbody>
  <tr>
  <td>1</td>
  <td>-1</td>
  <td>A</td>
  <td>0</td>
  </tr>
  <tr>
  <td>2</td>
  <td>1</td>
  <td>B</td>
  <td>0</td>
  </tr>
  <tr>
  <td>3</td>
  <td>1</td>
  <td>B</td>
  <td>1</td>
  </tr>
  <tr>
  <td>3</td>
  <td>2</td>
  <td>B</td>
  <td>1</td>
  </tr>
  </tbody>
  </table>
  </div>
  <p>Id compared with PreID.
  First Row ID 1 does not have Preid and Code is A so valid is 0. This is correct</p>
  <p>Second Row ID 2 and Preid  is 1 , code is B for ID 2 but code is A for ID 1 so valid is 0. This is correct</p>
  <p>Third Row Id is 3 and Preid is 1 , code is B for for id 3 but Code is A for Id 1 so valid should be 0 but displaying 1 which is incorrect</p>
  <p>Fourth Row Id is 4 and Preid is 1, code is B for for id 3 and Code is B for Id 2 so valid is 1 which is correct.</p>
  <p>Trying to get valid 0 for third row.</p>
  <p>All of them are dimensions and  valid is measure.</p>
  <p>Is it possible to compare the Code column of Key and pre key without adding new dimension ? currently it is looking at the Code column of only Key and not prekey and setting the valid 0 or 1.
  I have tried previousmember but as shown in example there will not be consistent rows of previousmemeber</p>