<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></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">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,<u></u><u></u></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)"><u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Regards,<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)">Richard<u></u><u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></span></p>
<p class="MsoNormal"><span style="font-size:11pt;font-family:Calibri,sans-serif;color:rgb(31,73,125)"><u></u> <u></u></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">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">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">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 lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif">From:</span></b><span lang="EN-US" style="font-size:11pt;font-family:Calibri,sans-serif"> Qgis-user <<a href="mailto:qgis-user-bounces@lists.osgeo.org" target="_blank">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">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<u></u><u></u></span></p>
</div>
</div>
<p class="MsoNormal"><u></u> <u></u></p>
<p class="MsoNormal">Hi,<u></u><u></u></p>
<div>
<p class="MsoNormal" style="margin-bottom:12pt">Does anyone have an idea?<u></u><u></u></p>
<div>
<p class="MsoNormal">Nicolas Cadieux<u></u><u></u></p>
<div>
<p class="MsoNormal"><a href="https://gitlab.com/njacadieux" target="_blank">https://gitlab.com/njacadieux</a><u></u><u></u></p>
</div>
</div>
<div>
<p class="MsoNormal"><br>
<br>
<u></u><u></u></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">njacadieux.gitlab@gmail.com</a>> a écrit :<u></u><u></u></p>
</blockquote>
</div>
<blockquote style="margin-top:5pt;margin-bottom:5pt">
<div>
<p class="MsoNormal"><span style="font-family:Tahoma,sans-serif"></span> <u></u>
<u></u></p>
<p>Hi,<u></u><u></u></p>
<p>I am creating a model that fixes Network files before they are used in the QGIS Network analysis (Shortest path) tools.<u></u><u></u></p>
<p>This is my work flow:<u></u><u></u></p>
<ol start="1" type="1">
<li class="MsoNormal">
Create a "Length" field (value) and calculate $length in the field calculator<u></u><u></u></li><li class="MsoNormal">
Split the Multipart lines into Singlepart lines<u></u><u></u></li><li class="MsoNormal">
Create a "Length<b>2</b>" field (value) and calculate $length in the field calculator<u></u><u></u></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)<u></u><u></u></li></ol>
<p>This works well<u></u><u></u></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:<u></u><u></u></p>
<ol start="1" type="1">
<li class="MsoNormal">
User input "Length" in the Model input. (@NamelengthField)<u></u><u></u></li><li class="MsoNormal">
Create a "Length" field using  @NamelengthField (as pre-calculated value) and calculate $length in the field calculator: This is OK<u></u><u></u></li><li class="MsoNormal">
Split the Multipart lines into Singlepart lines: This is OK<u></u><u></u></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.
<u></u><u></u></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.<u></u><u></u></li></ol>
<p>I tried stuff like<u></u><u></u></p>
<p>@NamelengthField != (@NamelengthField || '2')<u></u><u></u></p>
<p>'@NamelengthField != @NamelengthField || '2''<u></u><u></u></p>
<p>"@NamelengthField != @NamelengthField || '2'"<u></u><u></u></p>
<p>"@NamelengthField"|| !=|| "@NamelengthField || '2'"<u></u><u></u></p>
<p>Even simple @NamelengthField = 5.286365157529550 (which should extract exactly one value). 
<u></u><u></u></p>
<p>Any ideas?<u></u><u></u></p>
<p>Nicolas<u></u><u></u></p>
<p>QGIS 3.18.2 on Windows 10 <u></u><u></u></p>
<p><u></u> <u></u></p>
<p><u></u> <u></u></p>
<p><u></u> <u></u></p>
<pre>-- <u></u><u></u></pre>
<pre>Nicolas Cadieux<u></u><u></u></pre>
<pre><a href="https://gitlab.com/njacadieux" target="_blank">https://gitlab.com/njacadieux</a><u></u><u></u></pre>
</div>
</blockquote>
</div>
</div>
</div>
</div>

_______________________________________________<br>
Qgis-user mailing list<br>
<a href="mailto:Qgis-user@lists.osgeo.org" target="_blank">Qgis-user@lists.osgeo.org</a><br>
List info: <a href="https://lists.osgeo.org/mailman/listinfo/qgis-user" rel="noreferrer" target="_blank">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">https://lists.osgeo.org/mailman/listinfo/qgis-user</a><br>
</blockquote></div>