<html>
    <head>
      <base href="https://bugs.documentfoundation.org/">
    </head>
    <body><table border="1" cellspacing="0" cellpadding="8">
        <tr>
          <th>Bug ID</th>
          <td><a class="bz_bug_link 
          bz_status_UNCONFIRMED "
   title="UNCONFIRMED - AutoFilter sort reference not updated with nested IF statement"
   href="https://bugs.documentfoundation.org/show_bug.cgi?id=138896">138896</a>
          </td>
        </tr>

        <tr>
          <th>Summary</th>
          <td>AutoFilter sort reference not updated with nested IF statement
          </td>
        </tr>

        <tr>
          <th>Product</th>
          <td>LibreOffice
          </td>
        </tr>

        <tr>
          <th>Version</th>
          <td>7.0.3.1 release
          </td>
        </tr>

        <tr>
          <th>Hardware</th>
          <td>All
          </td>
        </tr>

        <tr>
          <th>OS</th>
          <td>Windows (All)
          </td>
        </tr>

        <tr>
          <th>Status</th>
          <td>UNCONFIRMED
          </td>
        </tr>

        <tr>
          <th>Severity</th>
          <td>normal
          </td>
        </tr>

        <tr>
          <th>Priority</th>
          <td>medium
          </td>
        </tr>

        <tr>
          <th>Component</th>
          <td>Calc
          </td>
        </tr>

        <tr>
          <th>Assignee</th>
          <td>libreoffice-bugs@lists.freedesktop.org
          </td>
        </tr>

        <tr>
          <th>Reporter</th>
          <td>that.man.colin@gmail.com
          </td>
        </tr></table>
      <p>
        <div>
        <pre>Description:
If a cell contains nested IF statement and the cell is part of an array of
AUTO-FILTERED cells, then reversing the sort from Ascending to Descending only
updates the cell reference for the first IF statement.
The parameter is set to [SORT] in Tools> Options> LO Calc> General

Steps to Reproduce:
Spreadsheet Attached. Future dates have been filtered out in Column C. These
are "exposed" as the process ages. The sheet is only sorted - Ascending - when
extra processing weeks are added. It is normally utilised with the current date
as the primary focus. No difference is observed if the column & row freeze is
inactivated.

The formula simply tests for the current event and displays the intermediate
change at that location only. Well, that's what it does when the auto-filter
sorting is ascending order.

Note the cell references in Cell M10
   =IF(J10="";"";IF(J11="";SUM(J7:J10);""))
Note the cell references and result in Cell M434
 =IF(J434="";"";IF(J435="";SUM(J431:J434);""))
Sort Descending on Column Filter B
Note the cell references and result in Cell M56 (The last pertinent cell)
 =IF(J56="";"";IF(J55="";SUM(J431:J434);""))

It may well be that you professionals have a better formula or knowledge of an
intrinsic CALC function that doesn't put a spanner in the works but I wouldn't
expect this fairly simplistic effort to cause an error.

Actual Results:
Reference and result corrupted

Expected Results:
No corruption


Reproducible: Always


User Profile Reset: No


OpenGL enabled: Yes

Additional Info:
Version: 7.0.3.1 (x64)
Build ID: d7547858d014d4cf69878db179d326fc3483e082
CPU threads: 4; OS: Windows 10.0 Build 19042; UI render: Skia/Raster; VCL: win
Locale: sv-SE (en_GB); UI: en-GB
Calc: threaded</pre>
        </div>
      </p>


      <hr>
      <span>You are receiving this mail because:</span>

      <ul>
          <li>You are the assignee for the bug.</li>
      </ul>
    </body>
</html>