<?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 Re: Using a variable to format a measure by expression in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Using-a-variable-to-format-a-measure-by-expression/m-p/1804507#M65363</link>
    <description>&lt;P&gt;One intend would be to show numbers in a correctly rounded format with exactly one decimal and K M B ... afterwards for respective blocks of thousands.&lt;/P&gt;&lt;P&gt;currently we applied the following formatting varibale to almost all metrics in the apps:&lt;/P&gt;&lt;P&gt;SET vNumericalAbbreviation = 'dual(if(fabs($1)&amp;gt;=1000, if(fabs($1)&amp;gt;=1000000, round($1/1000000,0.1)&amp;amp;chr(77),round($1/1000,0.1)&amp;amp;chr(107)),round($1,0.1)),$1)';&lt;/P&gt;&lt;P&gt;Moving the set expressions itself into script wouldn't be a viable option because then users can't do ad-hoc changes.&amp;nbsp;Replacing the escaped character might work, though it will increase complexity even further.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Up until now I tried to separate the , parts e.g by using * but we recently stumbled across one expression which i didn't know how to rewrite. Splitting the whole expression into multiple blocks wouldn't work because the variable function needs to wrap the whole expression.&lt;/P&gt;&lt;P&gt;atm we use&lt;/P&gt;&lt;P&gt;sum({$&amp;lt;Sonderfall,Kostenart_Zusammenfassung,Jahr={"$(varCurrentYear)"}&amp;gt;*&amp;lt;Sonderfall,Kostenart_Zusammenfassung,timestamp={'$(importZeitpunkt)'}&amp;gt;*&amp;lt;Sonderfall,Kostenart_Zusammenfassung,Risikokategorie-={3}&amp;gt;} [Risiko-Wert])&lt;/P&gt;&lt;P&gt;it is important that some dimensions are always filtered the same way while others should be filtered depening on the current analysis state. (dimensions not listed in the expression) In order to exclude "Sonderfall" and "Kostenart ..." dimensions from the filter we had to add them with , a simple | would not work because then there would also be entrys which should have been filtered by the other set modifiers... (unless you could use logical brackets in set expressions - which to my knowledge you can't&lt;/P&gt;</description>
    <pubDate>Mon, 03 May 2021 07:55:20 GMT</pubDate>
    <dc:creator>benste</dc:creator>
    <dc:date>2021-05-03T07:55:20Z</dc:date>
    <item>
      <title>Using a variable to format a measure by expression</title>
      <link>https://community.qlik.com/t5/App-Development/Using-a-variable-to-format-a-measure-by-expression/m-p/1804238#M65333</link>
      <description>&lt;P&gt;Hello dear experts,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to make use of formatting a measure by expression, setting "&lt;SPAN&gt;Measure expression" in the KPI object.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I defined a variable in script to implement a desired formatting.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;SET X = 'round($1/1000,0.1)&amp;amp;CHR(77)';&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;Data:&lt;BR /&gt;LOAD * INLINE [&lt;BR /&gt;Dim, Sales&lt;BR /&gt;A, 150&lt;BR /&gt;A, 200&lt;BR /&gt;B, 240&lt;BR /&gt;B, 230&lt;BR /&gt;C, 410&lt;BR /&gt;C, 330&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;So far so good, it works with expression like&amp;nbsp;&lt;STRONG&gt;$(X(sum({&amp;lt;Dim={A}&amp;gt;}Sales)))&lt;/STRONG&gt;, but as soon as I need to use a comma in the set expression it does not work, like&amp;nbsp;&lt;STRONG&gt;$(X(sum({&amp;lt;Dim={A}, Dim&amp;gt;}Sales)))&lt;/STRONG&gt;.&lt;/P&gt;&lt;P&gt;I definitely want to make I use of the the option ""&lt;SPAN&gt;Measure expression" for formatting, my business case is more complex, but this examples shows that using a comma is problematic.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Does anybody have an idea how to solve this?&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;&lt;FONT color="#FF0000"&gt;I also attached a sample QVF with this example.&lt;/FONT&gt;&lt;/STRONG&gt;&lt;/P&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="2021-04-30_17-11-59.jpg" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/54048i4C2ECCA2AF875EAF/image-size/large?v=v2&amp;amp;px=999" role="button" title="2021-04-30_17-11-59.jpg" alt="2021-04-30_17-11-59.jpg" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt; &lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 00:11:55 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Using-a-variable-to-format-a-measure-by-expression/m-p/1804238#M65333</guid>
      <dc:creator>Eddy</dc:creator>
      <dc:date>2024-11-16T00:11:55Z</dc:date>
    </item>
    <item>
      <title>Re: Using a variable to format a measure by expression</title>
      <link>https://community.qlik.com/t5/App-Development/Using-a-variable-to-format-a-measure-by-expression/m-p/1804353#M65341</link>
      <description>&lt;P&gt;Hi, you can use a variable to store the expression and pass that variable:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;SET expr1 = =Sum({&amp;lt;Dim={A}&amp;gt;} Sales);
SET expr2 = =Sum({&amp;lt;Dim={A},Dim&amp;gt;} Sales);
SET X = round($1/1000,0.1)&amp;amp;CHR(77);&lt;/LI-CODE&gt;&lt;P&gt;$(X(expr1))&lt;/P&gt;&lt;P&gt;$(X(expr2))&lt;/P&gt;</description>
      <pubDate>Sat, 01 May 2021 07:59:39 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Using-a-variable-to-format-a-measure-by-expression/m-p/1804353#M65341</guid>
      <dc:creator>rubenmarin</dc:creator>
      <dc:date>2021-05-01T07:59:39Z</dc:date>
    </item>
    <item>
      <title>Re: Using a variable to format a measure by expression</title>
      <link>https://community.qlik.com/t5/App-Development/Using-a-variable-to-format-a-measure-by-expression/m-p/1804362#M65349</link>
      <description>&lt;P&gt;I think there is no general and therefore satisfying solution possible. The comma will be always treated as parameter-delimiter for the variable. There is no possibility to change the behaviour or to mask the comma.&lt;/P&gt;&lt;P&gt;This means you will need workarounds to get such logics to work. This may be to replace the comma with another char by calling the variable and the variable itself contained also a logic to revert it again. This could become rather tedious ... maybe suitable for certain use-cases but rather not for general approaches.&lt;/P&gt;&lt;P&gt;Depending on the intended scenarios it's also thinkable to structure the variables different especially splitting them into several parts to avoid the comma-issue and other difficulties which could occur by nesting variables. Again not really recommended for a general use.&lt;/P&gt;&lt;P&gt;More practically but not without challenges is to avoid the commas by using different syntaxes and/or functions, for example:&lt;/P&gt;&lt;P&gt;... {&amp;lt; Dim1 = {'a'}, Dim2 = {'b'} &amp;gt;} ...&lt;/P&gt;&lt;P&gt;could be written as&lt;/P&gt;&lt;P&gt;... {&amp;lt; Dim1 = {'a'} &amp;gt; * &amp;lt; Dim2 = {'b'} &amp;gt;} ...&lt;/P&gt;&lt;P&gt;and&lt;/P&gt;&lt;P&gt;... {&amp;lt; Dim1 = {'a', 'b'} &amp;gt;} ...&lt;/P&gt;&lt;P&gt;could be written as&lt;/P&gt;&lt;P&gt;... {&amp;lt; Dim1 = {(a|b)} &amp;gt;} ...&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;- Marcus&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 01 May 2021 10:06:11 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Using-a-variable-to-format-a-measure-by-expression/m-p/1804362#M65349</guid>
      <dc:creator>marcus_sommer</dc:creator>
      <dc:date>2021-05-01T10:06:11Z</dc:date>
    </item>
    <item>
      <title>Re: Using a variable to format a measure by expression</title>
      <link>https://community.qlik.com/t5/App-Development/Using-a-variable-to-format-a-measure-by-expression/m-p/1804507#M65363</link>
      <description>&lt;P&gt;One intend would be to show numbers in a correctly rounded format with exactly one decimal and K M B ... afterwards for respective blocks of thousands.&lt;/P&gt;&lt;P&gt;currently we applied the following formatting varibale to almost all metrics in the apps:&lt;/P&gt;&lt;P&gt;SET vNumericalAbbreviation = 'dual(if(fabs($1)&amp;gt;=1000, if(fabs($1)&amp;gt;=1000000, round($1/1000000,0.1)&amp;amp;chr(77),round($1/1000,0.1)&amp;amp;chr(107)),round($1,0.1)),$1)';&lt;/P&gt;&lt;P&gt;Moving the set expressions itself into script wouldn't be a viable option because then users can't do ad-hoc changes.&amp;nbsp;Replacing the escaped character might work, though it will increase complexity even further.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Up until now I tried to separate the , parts e.g by using * but we recently stumbled across one expression which i didn't know how to rewrite. Splitting the whole expression into multiple blocks wouldn't work because the variable function needs to wrap the whole expression.&lt;/P&gt;&lt;P&gt;atm we use&lt;/P&gt;&lt;P&gt;sum({$&amp;lt;Sonderfall,Kostenart_Zusammenfassung,Jahr={"$(varCurrentYear)"}&amp;gt;*&amp;lt;Sonderfall,Kostenart_Zusammenfassung,timestamp={'$(importZeitpunkt)'}&amp;gt;*&amp;lt;Sonderfall,Kostenart_Zusammenfassung,Risikokategorie-={3}&amp;gt;} [Risiko-Wert])&lt;/P&gt;&lt;P&gt;it is important that some dimensions are always filtered the same way while others should be filtered depening on the current analysis state. (dimensions not listed in the expression) In order to exclude "Sonderfall" and "Kostenart ..." dimensions from the filter we had to add them with , a simple | would not work because then there would also be entrys which should have been filtered by the other set modifiers... (unless you could use logical brackets in set expressions - which to my knowledge you can't&lt;/P&gt;</description>
      <pubDate>Mon, 03 May 2021 07:55:20 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Using-a-variable-to-format-a-measure-by-expression/m-p/1804507#M65363</guid>
      <dc:creator>benste</dc:creator>
      <dc:date>2021-05-03T07:55:20Z</dc:date>
    </item>
  </channel>
</rss>

