BO webi variable giving second max instread of max
<p>I have been trying to fetch the max of a date variable and when I try to do so, webi gives me second max date instead of the max. </p>

<pre><code>   [Var_tran_date]= If([Part Tran Type]="D") Then     
                      (FormatDate(ToDate("10/10/10";"MM/dd/yy");"MM/dd/yy"))ForEach ([SBA,CAA,TDA].[Foracid])
                    Else
                      [Tran Date]
</code></pre>

<p>foracid here being the account number, The max varible is defined as:</p>

<pre><code>   var_maxdate=Max([Var_tran_date]) In ([SBA,CAA,TDA].[Foracid])
</code></pre>

<p>and the result is giving me second max date for each account number instead of max.</p>

<p><a href="https://i.stack.imgur.com/gNEZm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gNEZm.png" alt="Max date snapshot (last column)"></a></p>

<p>I am unable to fetch the max date. </p>