<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Strange Behavior Removing Leading Zeros in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Strange-Behavior-Removing-Leading-Zeros/m-p/1973850#M1220676</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;Recently I came across a strange behavior, and wanted to check forum whether there is a solution.&lt;/P&gt;
&lt;P&gt;In QlikView Script, I want to load below 2 text records&amp;nbsp; and remove leading zeros.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MuratErcan1_0-1661593531003.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/87627i2C682C9569B4F8A7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MuratErcan1_0-1661593531003.png" alt="MuratErcan1_0-1661593531003.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;However, whatever I try, I keep getting strange results. I am using the below script:&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="100%"&gt;T1:&lt;BR /&gt;LOAD&lt;BR /&gt;&amp;nbsp; &amp;nbsp; MAT,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Text(MAT) AS MAT_TXT,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Replace(Ltrim(Replace(Text(MAT), '0', ' ')), ' ', 0) AS MAT_NoZeros_1,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Replace(Ltrim(Replace(MAT, '0', ' ')), ' ', 0) AS MAT_NoZeros_2&lt;BR /&gt;;&lt;BR /&gt;LOAD * INLINE[&lt;BR /&gt;&amp;nbsp; &amp;nbsp; MAT&lt;BR /&gt;&amp;nbsp; &amp;nbsp; 0195-0012-10&lt;BR /&gt;&amp;nbsp; &amp;nbsp; 0195-0012-010&lt;BR /&gt;];&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am getting the below as the result.&amp;nbsp; "0" from the "010" is also dropped.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MuratErcan1_1-1661593888323.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/87628iC8DF51B8314F1633/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MuratErcan1_1-1661593888323.png" alt="MuratErcan1_1-1661593888323.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I know that Qlik engine stores "010" and "10" as one value when it is a numeric field, but in this case it is a text field and 010 is not even in the beginning.&lt;/P&gt;
&lt;P&gt;I guess Somehow, "-" character is causing Qlik engine to store values as separate numeric values??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even more strange is, the behavior changes when there is only one "-" character. when I load below 2 entries instead, result is as expected. "010" and "10" of these strings are interpreted correctly.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MuratErcan1_3-1661594348331.png" style="width: 103px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/87630i9271385B7C6CF18F/image-dimensions/103x95?v=v2" width="103" height="95" role="button" title="MuratErcan1_3-1661594348331.png" alt="MuratErcan1_3-1661594348331.png" /&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MuratErcan1_2-1661594303315.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/87629iDC034082D53324E4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MuratErcan1_2-1661594303315.png" alt="MuratErcan1_2-1661594303315.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have tried replacing "-" with "|", removing leading zeros and then replacing "|" back to "-".&amp;nbsp; Removing leading zeros worked with "|" character, but when replace them with "-", bam! leading zeros starts appearing again.&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="100%"&gt;T1:&lt;BR /&gt;LOAD&lt;BR /&gt;&amp;nbsp; &amp;nbsp; MAT_NoZeros_3,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Replace(MAT_NoZeros_3,'|','-') AS MAT_NoZeros_4&lt;BR /&gt;;&lt;BR /&gt;LOAD&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Replace(Ltrim(Replace(&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Replace(Text(MAT),'-','|')&lt;BR /&gt;&amp;nbsp; &amp;nbsp; , '0', ' ')), ' ', 0) AS MAT_NoZeros_3&lt;BR /&gt;;&lt;BR /&gt;LOAD * INLINE[&lt;BR /&gt;MAT&lt;BR /&gt;&amp;nbsp; &amp;nbsp; 0195-0012-010&lt;BR /&gt;&amp;nbsp; &amp;nbsp; 0195-0012-10&lt;BR /&gt;];&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MuratErcan1_4-1661595378277.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/87631iE7BD9BD8DAF45339/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MuratErcan1_4-1661595378277.png" alt="MuratErcan1_4-1661595378277.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any thoughts on how to handle this? Any help is much appreciated!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Murat&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 27 Aug 2022 10:18:33 GMT</pubDate>
    <dc:creator>MuratErcan1</dc:creator>
    <dc:date>2022-08-27T10:18:33Z</dc:date>
    <item>
      <title>Strange Behavior Removing Leading Zeros</title>
      <link>https://community.qlik.com/t5/QlikView/Strange-Behavior-Removing-Leading-Zeros/m-p/1973850#M1220676</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;Recently I came across a strange behavior, and wanted to check forum whether there is a solution.&lt;/P&gt;
&lt;P&gt;In QlikView Script, I want to load below 2 text records&amp;nbsp; and remove leading zeros.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MuratErcan1_0-1661593531003.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/87627i2C682C9569B4F8A7/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MuratErcan1_0-1661593531003.png" alt="MuratErcan1_0-1661593531003.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;However, whatever I try, I keep getting strange results. I am using the below script:&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="100%"&gt;T1:&lt;BR /&gt;LOAD&lt;BR /&gt;&amp;nbsp; &amp;nbsp; MAT,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Text(MAT) AS MAT_TXT,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Replace(Ltrim(Replace(Text(MAT), '0', ' ')), ' ', 0) AS MAT_NoZeros_1,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Replace(Ltrim(Replace(MAT, '0', ' ')), ' ', 0) AS MAT_NoZeros_2&lt;BR /&gt;;&lt;BR /&gt;LOAD * INLINE[&lt;BR /&gt;&amp;nbsp; &amp;nbsp; MAT&lt;BR /&gt;&amp;nbsp; &amp;nbsp; 0195-0012-10&lt;BR /&gt;&amp;nbsp; &amp;nbsp; 0195-0012-010&lt;BR /&gt;];&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am getting the below as the result.&amp;nbsp; "0" from the "010" is also dropped.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MuratErcan1_1-1661593888323.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/87628iC8DF51B8314F1633/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MuratErcan1_1-1661593888323.png" alt="MuratErcan1_1-1661593888323.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;I know that Qlik engine stores "010" and "10" as one value when it is a numeric field, but in this case it is a text field and 010 is not even in the beginning.&lt;/P&gt;
&lt;P&gt;I guess Somehow, "-" character is causing Qlik engine to store values as separate numeric values??&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Even more strange is, the behavior changes when there is only one "-" character. when I load below 2 entries instead, result is as expected. "010" and "10" of these strings are interpreted correctly.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MuratErcan1_3-1661594348331.png" style="width: 103px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/87630i9271385B7C6CF18F/image-dimensions/103x95?v=v2" width="103" height="95" role="button" title="MuratErcan1_3-1661594348331.png" alt="MuratErcan1_3-1661594348331.png" /&gt;&lt;/span&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MuratErcan1_2-1661594303315.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/87629iDC034082D53324E4/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MuratErcan1_2-1661594303315.png" alt="MuratErcan1_2-1661594303315.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I have tried replacing "-" with "|", removing leading zeros and then replacing "|" back to "-".&amp;nbsp; Removing leading zeros worked with "|" character, but when replace them with "-", bam! leading zeros starts appearing again.&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="100%"&gt;T1:&lt;BR /&gt;LOAD&lt;BR /&gt;&amp;nbsp; &amp;nbsp; MAT_NoZeros_3,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Replace(MAT_NoZeros_3,'|','-') AS MAT_NoZeros_4&lt;BR /&gt;;&lt;BR /&gt;LOAD&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Replace(Ltrim(Replace(&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Replace(Text(MAT),'-','|')&lt;BR /&gt;&amp;nbsp; &amp;nbsp; , '0', ' ')), ' ', 0) AS MAT_NoZeros_3&lt;BR /&gt;;&lt;BR /&gt;LOAD * INLINE[&lt;BR /&gt;MAT&lt;BR /&gt;&amp;nbsp; &amp;nbsp; 0195-0012-010&lt;BR /&gt;&amp;nbsp; &amp;nbsp; 0195-0012-10&lt;BR /&gt;];&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="MuratErcan1_4-1661595378277.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/87631iE7BD9BD8DAF45339/image-size/medium?v=v2&amp;amp;px=400" role="button" title="MuratErcan1_4-1661595378277.png" alt="MuratErcan1_4-1661595378277.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Any thoughts on how to handle this? Any help is much appreciated!&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thanks,&lt;/P&gt;
&lt;P&gt;Murat&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 27 Aug 2022 10:18:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Strange-Behavior-Removing-Leading-Zeros/m-p/1973850#M1220676</guid>
      <dc:creator>MuratErcan1</dc:creator>
      <dc:date>2022-08-27T10:18:33Z</dc:date>
    </item>
    <item>
      <title>Re: Strange Behavior Removing Leading Zeros</title>
      <link>https://community.qlik.com/t5/QlikView/Strange-Behavior-Removing-Leading-Zeros/m-p/1973897#M1220678</link>
      <description>&lt;P&gt;Just wrap the expression around with Text() to ensure it is treated as such.&lt;/P&gt;
&lt;P&gt;&lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;Text(&lt;/STRONG&gt; &lt;/FONT&gt;Replace(Ltrim(Replace(Text(MAT), '0', ' ')), ' ', 0) &lt;FONT color="#FF0000"&gt;&lt;STRONG&gt;) &lt;/STRONG&gt;&lt;/FONT&gt;AS MAT_NoZeros_1&lt;/P&gt;</description>
      <pubDate>Sat, 27 Aug 2022 19:54:41 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Strange-Behavior-Removing-Leading-Zeros/m-p/1973897#M1220678</guid>
      <dc:creator>BrunPierre</dc:creator>
      <dc:date>2022-08-27T19:54:41Z</dc:date>
    </item>
  </channel>
</rss>

