<?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 At what stage should we apply number formatting? in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/At-what-stage-should-we-apply-number-formatting/m-p/1701129#M53680</link>
    <description>&lt;P&gt;Which of the following two methods is considered best practice? In reality, the data would be loaded from a database, file, or qvd.&lt;/P&gt;&lt;P&gt;1) Leaving the field unformatted and applying formatting to the measure.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;LOAD
    m_quantity,
INLINE [
    m_quantity
    1000
    2000
];
Set vm_quantity = Num(Sum(m_quantity), '#,##0');&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) Applying formatting to the field and letting it propagate to the measure.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;LOAD
    Num(m_quantity, '#,##0') AS m_quantityF
INLINE [
    m_quantity
    1000
    2000
];
Set vm_quantity = Sum(m_quantityF);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been doing method 1, but now that I'm aiming to build up a data warehouse of qvds, I'm considering using method 2 to push more code from user apps into qvd-loading apps and to encourage more standardized number formatting.&lt;/P&gt;&lt;P&gt;Then again, the nice thing about method 1 is that it &lt;EM&gt;always&lt;/EM&gt; works, whereas applying formatting to fields is fragile. I experimented to see how field formatting propagates and found that if you do &lt;EM&gt;anything&lt;/EM&gt; to the field other than wrapping it in an aggregation, you lose the formatting. For instance, all of the trivial formulas below remove that field's formatting. And the legitimate scenario of calculating one field based on others also kills the formatting, even if every source column had the exact same formatting.&amp;nbsp; So what's best?&amp;nbsp; Try for method two and supplement it with method one as needed?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Set vm_quantity = Sum(m_quantityF * 1);
Set vm_quantity = Sum(m_quantityF + 0);
Set vm_quantity = Sum(m_quantityF) * 1;
Set vm_quantity = Sum(m_quantityF) + 0;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 02:28:07 GMT</pubDate>
    <dc:creator>mmarchese</dc:creator>
    <dc:date>2024-11-16T02:28:07Z</dc:date>
    <item>
      <title>At what stage should we apply number formatting?</title>
      <link>https://community.qlik.com/t5/App-Development/At-what-stage-should-we-apply-number-formatting/m-p/1701129#M53680</link>
      <description>&lt;P&gt;Which of the following two methods is considered best practice? In reality, the data would be loaded from a database, file, or qvd.&lt;/P&gt;&lt;P&gt;1) Leaving the field unformatted and applying formatting to the measure.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;LOAD
    m_quantity,
INLINE [
    m_quantity
    1000
    2000
];
Set vm_quantity = Num(Sum(m_quantity), '#,##0');&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) Applying formatting to the field and letting it propagate to the measure.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;LOAD
    Num(m_quantity, '#,##0') AS m_quantityF
INLINE [
    m_quantity
    1000
    2000
];
Set vm_quantity = Sum(m_quantityF);&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've been doing method 1, but now that I'm aiming to build up a data warehouse of qvds, I'm considering using method 2 to push more code from user apps into qvd-loading apps and to encourage more standardized number formatting.&lt;/P&gt;&lt;P&gt;Then again, the nice thing about method 1 is that it &lt;EM&gt;always&lt;/EM&gt; works, whereas applying formatting to fields is fragile. I experimented to see how field formatting propagates and found that if you do &lt;EM&gt;anything&lt;/EM&gt; to the field other than wrapping it in an aggregation, you lose the formatting. For instance, all of the trivial formulas below remove that field's formatting. And the legitimate scenario of calculating one field based on others also kills the formatting, even if every source column had the exact same formatting.&amp;nbsp; So what's best?&amp;nbsp; Try for method two and supplement it with method one as needed?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;Set vm_quantity = Sum(m_quantityF * 1);
Set vm_quantity = Sum(m_quantityF + 0);
Set vm_quantity = Sum(m_quantityF) * 1;
Set vm_quantity = Sum(m_quantityF) + 0;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 02:28:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/At-what-stage-should-we-apply-number-formatting/m-p/1701129#M53680</guid>
      <dc:creator>mmarchese</dc:creator>
      <dc:date>2024-11-16T02:28:07Z</dc:date>
    </item>
    <item>
      <title>Re: At what stage should we apply number formatting?</title>
      <link>https://community.qlik.com/t5/App-Development/At-what-stage-should-we-apply-number-formatting/m-p/1701230#M53689</link>
      <description>&lt;P&gt;I tend to favor approach #1, delay formatting until the measure.&amp;nbsp; Primary reason is storage.&amp;nbsp; Numbers formatted in the script will usually be stored as duals -- storing both numeric and string -- using more RAM and disk space.&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;</description>
      <pubDate>Tue, 12 May 2020 18:12:44 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/At-what-stage-should-we-apply-number-formatting/m-p/1701230#M53689</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2020-05-12T18:12:44Z</dc:date>
    </item>
    <item>
      <title>Re: At what stage should we apply number formatting?</title>
      <link>https://community.qlik.com/t5/App-Development/At-what-stage-should-we-apply-number-formatting/m-p/1701242#M53691</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/6148"&gt;@rwunderlich&lt;/a&gt;&amp;nbsp;Thanks for the reply.&amp;nbsp; Interesting.&amp;nbsp; I'm trying to understand this fully:&lt;/P&gt;&lt;P&gt;So if you leave a numeric field unformatted, it consumes less memory?&amp;nbsp; I thought I read somewhere that everything is a dual in Qlik, but I guess not?&amp;nbsp; Maybe I misinterpreted the statement, "There are no data types in Qlikview" from &lt;A href="https://community.qlik.com/t5/Qlik-Design-Blog/Data-Types-in-QlikView/ba-p/1474977" target="_self"&gt;this article about duals&lt;/A&gt;.&amp;nbsp; Anyway, in light of what you said about memory, I'm trying to picture how it works.&amp;nbsp; Does Qlik do something like this?&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Store both the number and the string if a function was used that returns a dual, such as Dual(), Date(), Num(), etc.&lt;/LI&gt;&lt;LI&gt;Otherwise, if the field is numeric, store only a number.&lt;/LI&gt;&lt;LI&gt;Otherwise, if the field is non-numeric, store only a string.&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Also, the memory impact&amp;nbsp;would only be in the symbol table, not the data table (borrowing&amp;nbsp;terminology from &lt;A href="https://community.qlik.com/t5/Qlik-Design-Blog/Symbol-Tables-and-Bit-Stuffed-Pointers/ba-p/1475369" target="_self"&gt;here&lt;/A&gt;), right?&amp;nbsp; So if you didn't have many unique values, the difference in memory consumption would be negligible.&lt;/P&gt;</description>
      <pubDate>Tue, 12 May 2020 19:26:45 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/At-what-stage-should-we-apply-number-formatting/m-p/1701242#M53691</guid>
      <dc:creator>mmarchese</dc:creator>
      <dc:date>2020-05-12T19:26:45Z</dc:date>
    </item>
    <item>
      <title>Re: At what stage should we apply number formatting?</title>
      <link>https://community.qlik.com/t5/App-Development/At-what-stage-should-we-apply-number-formatting/m-p/1701283#M53699</link>
      <description>&lt;P&gt;Yes, I would agree with all of your statements.&amp;nbsp; I would make a slight tweak to your #1, in that Dates, even though "Dual", may be stored slightly more optimized. See here for more&amp;nbsp;&lt;A href="https://qlikviewcookbook.com/2017/03/dual-storage-vs-dual-behavior/" target="_blank"&gt;https://qlikviewcookbook.com/2017/03/dual-storage-vs-dual-behavior/&lt;/A&gt;. This detail is not really significant to your original question.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, it impacts only symbol table storage and in many cases the increase is negligible. So if pre-formatting makes you more efficient in some way, the trade off may be worth it.&lt;/P&gt;&lt;P&gt;The increase in symbol size is also reflected in QVDs, something of more concern to some folks.&amp;nbsp;&lt;/P&gt;&lt;P&gt;-Rob&lt;/P&gt;</description>
      <pubDate>Tue, 12 May 2020 22:41:47 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/At-what-stage-should-we-apply-number-formatting/m-p/1701283#M53699</guid>
      <dc:creator>rwunderlich</dc:creator>
      <dc:date>2020-05-12T22:41:47Z</dc:date>
    </item>
    <item>
      <title>Re: At what stage should we apply number formatting?</title>
      <link>https://community.qlik.com/t5/App-Development/At-what-stage-should-we-apply-number-formatting/m-p/1701612#M53732</link>
      <description>&lt;P&gt;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/6148"&gt;@rwunderlich&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Ok, I suppose I'll stick to approach 1 for now (formatting measures, not fields).&lt;/P&gt;&lt;P&gt;I just read the article of yours, as well as your other one &lt;A href="https://qlikviewcookbook.com/2008/05/when-less-data-means-more-ram/" target="_self"&gt;here&lt;/A&gt;.&amp;nbsp; Unfortunately, my main takeaway is that Qlik is a mysterious black box.&amp;nbsp; I say that because I have no idea what the rules are for when Date() and Num() fields are stored as true duals (one number and one string per row) vs "implied duals" (one number per row + a single formatting string).&amp;nbsp; The only rule I know (based on your articles) is that if a date field is referenced by a WHERE clause, it will be forced to a true dual and that using Date(Num(DateField)) will force it back to an implied dual.&amp;nbsp; Neither of those behaviors makes much intuitive sense to me, but I trust that you are correct.&amp;nbsp; Is there anywhere else I could learn more about these nuances?&lt;/P&gt;</description>
      <pubDate>Wed, 13 May 2020 14:34:10 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/At-what-stage-should-we-apply-number-formatting/m-p/1701612#M53732</guid>
      <dc:creator>mmarchese</dc:creator>
      <dc:date>2020-05-13T14:34:10Z</dc:date>
    </item>
  </channel>
</rss>

