<html>
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
  </head>
  <body>
    <p>Hi,</p>
    <p>if(attribute(to_string( @<span style="font-family:monospace">NamelengthField</span>
      )) != "LENGTH2", TRUE, FALSE ) <br>
    </p>
    <p>("LENGHT2" is an existing field and @<span
        style="font-family:monospace">NamelengthField</span> was a model
      input string.)<br>
    </p>
    <p>This worked  for me!   If you have the time, please explain why I
      needed the <u>attribute()</u> function for this to work.  I
      looked in the documentation and did not find it very clear.</p>
    <p>Thanks a million you saved my butt!<br>
    </p>
    <p>Nicolas<br>
    </p>
    <p><br>
    </p>
    <div class="moz-cite-prefix">On 2021-07-20 5:53 a.m., Charles
      Dixon-Paver wrote:<br>
    </div>
    <blockquote type="cite"
cite="mid:CAK2Kqif75Vt0scX81P6NH55yuksw4u+KkkELozE_DOzFBstM2w@mail.gmail.com">
      <meta http-equiv="content-type" content="text/html; charset=UTF-8">
      <div dir="ltr">Hi Nicholas,
        <div><br>
        </div>
        <div>I haven't had time to dig into this extensively or
          encountered this particular issue, but I would suggest trying
          to "force" the expression to retrieve the correct info
          regardless of context using something like this:</div>
        <div><br>
        </div>
        <span style="font-family:monospace">with_variable('Length2',
           to_string(@NamelengthField) || '2',
          if(attribute(to_string(@NamelengthField)) !=
          attribute(@Length2), TRUE, FALSE))</span><br>
        <div><br>
        </div>
        <div>That's probably an extreme example but hopefully it
          illustrates my point. If you want to share a sample dataset/
          model I can try to have a look at how to resolve it.</div>
        <div><br>
        </div>
        <div>Regards</div>
      </div>
      <br>
      <div class="gmail_quote">
        <div dir="ltr" class="gmail_attr">On Tue, 20 Jul 2021 at 10:46,
          Richard McDonnell <<a
            href="mailto:richard.mcdonnell@opw.ie"
            moz-do-not-send="true">richard.mcdonnell@opw.ie</a>>
          wrote:<br>
        </div>
        <blockquote class="gmail_quote" style="margin:0px 0px 0px
          0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
          <div lang="EN-IE">
            <div class="gmail-m_-457134324710026911WordSection1">
              <p class="MsoNormal"><span
style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Nicolas,</span></p>
              <p class="MsoNormal"><span
style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">I
                  have not looked at this in too much detail, but at a
                  quick glance, could it not be the fact that you should
                  be using the newly created fields? As in instead of </span><b>@NamelengthField
                  != @NamelengthField || '2'</b>,
                <span
style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">should
                  it not be more like your previous example</span> <b>Length
                  != Length2</b><span
style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"></span></p>
              <p class="MsoNormal"><span
style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> </span></p>
              <p class="MsoNormal"><span
style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Regards,</span></p>
              <p class="MsoNormal"><span
style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> </span></p>
              <p class="MsoNormal"><span
style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Richard</span></p>
              <p class="MsoNormal"><span
style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> </span></p>
              <p class="MsoNormal"><span
style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"> </span></p>
              <table
style="font-size:9pt;height:321px;font-family:Arial,sans-serif;width:500px;line-height:15px"
                cellspacing="0" cellpadding="0">
                <tbody>
                  <tr>
                    <td
style="font-size:9pt;font-family:Arial,sans-serif;width:500px;color:rgb(0,77,68);padding-bottom:6px"><span
style="font-family:Arial,sans-serif;font-weight:bold;color:rgb(0,77,68)"><br>
                        ——</span><br>
                      <span
                        style="font-family:Arial,sans-serif;font-weight:bold;color:rgb(0,77,68)">Richard
                        McDonnell MSc GIS, FME Certified Professional</span><br>
                      <span
                        style="font-family:Arial,sans-serif;color:rgb(0,77,68)"><i>FRM
                          Data Management</i></span><br>
                      <br>
                      <span
                        style="font-family:Arial,sans-serif;color:rgb(0,77,68)">——</span><br>
                      <span
                        style="font-family:Arial,sans-serif;font-weight:bold;color:rgb(0,77,68)">Oifig
                        na nOibreacha Poiblí</span><br>
                      <span
                        style="font-family:Arial,sans-serif;color:rgb(0,77,68)">Office
                        of Public Works</span><br>
                      <br>
                      <span
style="font-family:Arial,sans-serif;font-weight:bold;color:rgb(86,81,72)">Sráid
                        Jonathan Swift, Baile Átha Troim, Co na Mí, C15
                        NX36
                      </span><br>
                      <span
                        style="font-family:Arial,sans-serif;color:rgb(86,81,72)">Jonathan
                        Swift Street, Trim, Co Meath, C15 NX36</span><br>
                      <span
                        style="font-family:Arial,sans-serif;color:rgb(86,81,72)">——</span><br>
                      <span
                        style="font-family:Arial,sans-serif;color:rgb(86,81,72)">M
                        +353 87 688 5964 T +353 46 942 2409</span><br>
                      <a href="https://gov.ie/opw" target="_blank"
                        moz-do-not-send="true">https://gov.ie/opw</a><br>
                      <br>
                      <span
                        style="font-family:Arial,sans-serif;color:rgb(0,77,68)">——<br>
                        To send me files larger than 30MB, please use
                        the link below <a
                          href="https://filetransfer.opw.ie/filedrop/richard.mcdonnell@opw.ie"
                          target="_blank" moz-do-not-send="true">https://filetransfer.opw.ie/filedrop/richard.mcdonnell@opw.ie</a><br>
                      </span><br>
                      <span
                        style="font-family:Arial,sans-serif;color:rgb(0,77,68)">Email
                        Disclaimer: <a
href="https://www.gov.ie/en/organisation-information/439daf-email-disclaimer/"
                          target="_blank" moz-do-not-send="true">https://www.gov.ie/en/organisation-information/439daf-email-disclaimer/</a>
                      </span></td>
                  </tr>
                </tbody>
              </table>
              <div
style="border-top:none;border-right:none;border-bottom:none;border-left:1.5pt
                solid blue;padding:0cm 0cm 0cm 4pt">
                <div>
                  <div
style="border-right:none;border-bottom:none;border-left:none;border-top:1pt
                    solid rgb(225,225,225);padding:3pt 0cm 0cm">
                    <p class="MsoNormal"><b><span
                          style="font-size:11pt;font-family:Calibri,sans-serif"
                          lang="EN-US">From:</span></b><span
                        style="font-size:11pt;font-family:Calibri,sans-serif"
                        lang="EN-US"> Qgis-user <<a
                          href="mailto:qgis-user-bounces@lists.osgeo.org"
                          target="_blank" moz-do-not-send="true">qgis-user-bounces@lists.osgeo.org</a>>
                        <b>On Behalf Of </b>Nicolas Cadieux<br>
                        <b>Sent:</b> 20 July 2021 09:27<br>
                        <b>To:</b> Qgis Users List <<a
                          href="mailto:qgis-user@lists.osgeo.org"
                          target="_blank" moz-do-not-send="true">qgis-user@lists.osgeo.org</a>><br>
                        <b>Subject:</b> Re: [Qgis-user] Problem using
                        Model Inputs variable in an Select by expression
                        in the model Designer</span></p>
                  </div>
                </div>
                <p class="MsoNormal"> </p>
                <p class="MsoNormal">Hi,</p>
                <div>
                  <p class="MsoNormal" style="margin-bottom:12pt">Does
                    anyone have an idea?</p>
                  <div>
                    <p class="MsoNormal">Nicolas Cadieux</p>
                    <div>
                      <p class="MsoNormal"><a
                          href="https://gitlab.com/njacadieux"
                          target="_blank" moz-do-not-send="true">https://gitlab.com/njacadieux</a></p>
                    </div>
                  </div>
                  <div>
                    <p class="MsoNormal"><br>
                      <br>
                    </p>
                    <blockquote style="margin-top:5pt;margin-bottom:5pt">
                      <p class="MsoNormal" style="margin-bottom:12pt">Le
                        8 juill. 2021 à 01:17, Nicolas Cadieux <<a
                          href="mailto:njacadieux.gitlab@gmail.com"
                          target="_blank" moz-do-not-send="true">njacadieux.gitlab@gmail.com</a>>
                        a écrit :</p>
                    </blockquote>
                  </div>
                  <blockquote style="margin-top:5pt;margin-bottom:5pt">
                    <div>
                      <p class="MsoNormal"><span
                          style="font-family:Tahoma,sans-serif"></span>
                      </p>
                      <p>Hi,</p>
                      <p>I am creating a model that fixes Network files
                        before they are used in the QGIS Network
                        analysis (Shortest path) tools.</p>
                      <p>This is my work flow:</p>
                      <ol type="1" start="1">
                        <li class="MsoNormal">
                          Create a "Length" field (value) and calculate
                          $length in the field calculator</li>
                        <li class="MsoNormal">
                          Split the Multipart lines into Singlepart
                          lines</li>
                        <li class="MsoNormal">
                          Create a "Length<b>2</b>" field (value) and
                          calculate $length in the field calculator</li>
                        <li class="MsoNormal">
                          Select by expression Length != Length2.  This
                          basically gives me a selection of line that
                          have been modified by the Multipart to
                          Singlepart algorithm. (I get 8 results)</li>
                      </ol>
                      <p>This works well</p>
                      <p>The problem is when I create and Input String
                        to let the user create a "Length" field.  This
                        become a variable called @NamelengthField. My
                        work flow become:</p>
                      <ol type="1" start="1">
                        <li class="MsoNormal">
                          User input "Length" in the Model input.
                          (@NamelengthField)</li>
                        <li class="MsoNormal">
                          Create a "Length" field using 
                          @NamelengthField (as pre-calculated value) and
                          calculate $length in the field calculator:
                          This is OK</li>
                        <li class="MsoNormal">
                          Split the Multipart lines into Singlepart
                          lines: This is OK</li>
                        <li class="MsoNormal">
                          Create a "Length2" field using 
                          @NamelengthField ||'2'  (as pre-calculated
                          value) and calculate $length in the field
                          calculator: This is OK this field (Length2) is
                          created and calculated properly.
                        </li>
                        <li class="MsoNormal">
                          I get stuck  when I try Select by expression
                          using  @NamelengthField != @NamelengthField ||
                          '2' (as pre-calculated value) (I get all lines
                          back) and the test does not work.</li>
                      </ol>
                      <p>I tried stuff like</p>
                      <p>@NamelengthField != (@NamelengthField || '2')</p>
                      <p>'@NamelengthField != @NamelengthField || '2''</p>
                      <p>"@NamelengthField != @NamelengthField || '2'"</p>
                      <p>"@NamelengthField"|| !=|| "@NamelengthField ||
                        '2'"</p>
                      <p>Even simple @NamelengthField =
                        5.286365157529550 (which should extract exactly
                        one value). 
                      </p>
                      <p>Any ideas?</p>
                      <p>Nicolas</p>
                      <p>QGIS 3.18.2 on Windows 10 </p>
                      <p> </p>
                      <p> </p>
                      <p> </p>
                      <pre>-- </pre>
                      <pre>Nicolas Cadieux</pre>
                      <pre><a href="https://gitlab.com/njacadieux" target="_blank" moz-do-not-send="true">https://gitlab.com/njacadieux</a></pre>
                    </div>
                  </blockquote>
                </div>
              </div>
            </div>
          </div>
          _______________________________________________<br>
          Qgis-user mailing list<br>
          <a href="mailto:Qgis-user@lists.osgeo.org" target="_blank"
            moz-do-not-send="true">Qgis-user@lists.osgeo.org</a><br>
          List info: <a
            href="https://lists.osgeo.org/mailman/listinfo/qgis-user"
            rel="noreferrer" target="_blank" moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
          Unsubscribe: <a
            href="https://lists.osgeo.org/mailman/listinfo/qgis-user"
            rel="noreferrer" target="_blank" moz-do-not-send="true">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
        </blockquote>
      </div>
    </blockquote>
    <pre class="moz-signature" cols="72">-- 
Nicolas Cadieux
<a class="moz-txt-link-freetext" href="https://gitlab.com/njacadieux">https://gitlab.com/njacadieux</a></pre>
  </body>
</html>