<?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 nested function with comma arguments in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Using-nested-function-with-comma-arguments/m-p/2546793#M109988</link>
    <description>&lt;P&gt;Ah ok I think I understand it. The only issue with the embedding the calculation inside the format function - which is what I did initially - is I need to create one format function per calculation function. However I have several different custom calculation functions that Qlik doesnt support (for example one that does a weighted avg, one that does something else), and would like to use the same Format function for these different calculation to reduce redundancy. Hence my idea of simply using the Format function and passing it any function that returns a value (regardless of what the function does). Hope this makes sense&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 14 Apr 2026 10:02:27 GMT</pubDate>
    <dc:creator>johnnyjohn</dc:creator>
    <dc:date>2026-04-14T10:02:27Z</dc:date>
    <item>
      <title>Using nested function with comma arguments</title>
      <link>https://community.qlik.com/t5/App-Development/Using-nested-function-with-comma-arguments/m-p/2546776#M109982</link>
      <description>&lt;P&gt;I've been stuck on this problem for a few days now, slowly driving me crazy. I've looked all throughout this forum, but haven't found an instance of this specific issue.&amp;nbsp;&lt;/P&gt;&lt;P&gt;My problem is pretty involved, but I've distilled it down as much as possible to the below. The example below of course isn't my use case, it's just an easily reproducible example of the core behaviour I'm trying to achieve - using nested functions and evaluating their output inside other functions.&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I have a function, say&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Set f_Format = Pick(Match($1, 'num','text'), NUM($2), TEXT($2));&lt;/LI-CODE&gt;&lt;P&gt;It takes 2 parameters. $1 to choose whether the value will be formatted as a NUM or as TEXT, and $2 is the value to be formatted.&lt;/P&gt;&lt;P&gt;I have another function.&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;Set f_Calc = PICK(Match($1, 'add', 'sub'), $2 + $3, $2 - $3);&lt;/LI-CODE&gt;&lt;P&gt;This takes 3 parameters. $1 to decide whether to add, or subtract numbers. $2 and $3 takes two values to add or subtract.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to use the f_Calc function to decide what calculation to use (whether to add or subtract), return that value, then use that value in the f_Format function to format it accordingly. The issue I have is the commas in f_Calc are being used to parse f_Format, so f_Calc is never evaluated.&lt;/P&gt;&lt;LI-CODE lang="python"&gt;$(f_Format(
	'num',
	$(f_Calc('add',4,3))
))&lt;/LI-CODE&gt;&lt;DIV&gt;I've tried Set vs Let, escaping characters, using REPLACE(), using $ expansions, I can't get anything to work.&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;I'd appreciate any help,&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;Thanks a lot&lt;/DIV&gt;</description>
      <pubDate>Tue, 14 Apr 2026 07:33:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Using-nested-function-with-comma-arguments/m-p/2546776#M109982</guid>
      <dc:creator>johnnyjohn</dc:creator>
      <dc:date>2026-04-14T07:33:06Z</dc:date>
    </item>
    <item>
      <title>Re: Using nested function with comma arguments</title>
      <link>https://community.qlik.com/t5/App-Development/Using-nested-function-with-comma-arguments/m-p/2546781#M109984</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/109463"&gt;@johnnyjohn&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try with the following. In backend:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;FONT size="2" color="#808080"&gt;Set f_Format = Pick(Match($1, 'num','text'), NUM($5), TEXT($6));&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;FONT size="2" color="#808080"&gt;Set f_Calc = PICK(Match($1, 'add', 'sub'), $2 + $3, $2 - $3;&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In front end:&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2" color="#808080"&gt;&lt;EM&gt;$(f_Format('num',$(f_Calc('add',4,3))))&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I don't know exactly why removing the last ) in f_Calc is needed, but it works in my end.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind Regards&lt;/P&gt;
&lt;P&gt;Daniel&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2026 08:03:33 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Using-nested-function-with-comma-arguments/m-p/2546781#M109984</guid>
      <dc:creator>Daniel_Castella</dc:creator>
      <dc:date>2026-04-14T08:03:33Z</dc:date>
    </item>
    <item>
      <title>Re: Using nested function with comma arguments</title>
      <link>https://community.qlik.com/t5/App-Development/Using-nested-function-with-comma-arguments/m-p/2546789#M109986</link>
      <description>&lt;P&gt;Thanks a lot, this works for the example. I'm trying to transpose this to my actual problem, and struggling to implement in my solution.&lt;/P&gt;&lt;P&gt;Specifically I get stuck on trying to apply a formatting ( using NUM with another argument that is like '#,##0.0')&lt;/P&gt;&lt;P&gt;&lt;EM&gt;&lt;FONT size="2" color="#808080"&gt;Pick(Match($1, 'num','text'), NUM($5, $7), TEXT($6));&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;&lt;P&gt;Can you explain what the above is actually doing - in relation to the variables being declared, etc... I can't make heads or tails of this.&lt;/P&gt;&lt;P&gt;Many thanks&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2026 08:40:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Using-nested-function-with-comma-arguments/m-p/2546789#M109986</guid>
      <dc:creator>johnnyjohn</dc:creator>
      <dc:date>2026-04-14T08:40:40Z</dc:date>
    </item>
    <item>
      <title>Re: Using nested function with comma arguments</title>
      <link>https://community.qlik.com/t5/App-Development/Using-nested-function-with-comma-arguments/m-p/2546792#M109987</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/109463"&gt;@johnnyjohn&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I discovered a mistake in my previous formulas. Could you, please, try these ones?&lt;/P&gt;
&lt;P&gt;In backend:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;FONT size="2" color="#808080"&gt;set f_Format = Pick(Match($1, 'num','text'), NUM($(f_Calc($1,$2,$3))), TEXT($(f_Calc($1,$2,$3))));&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;FONT size="2" color="#808080"&gt;set f_Calc = PICK(Match($1, 'add', 'sub'), $2 + $3, $2 - $3);&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In front end:&lt;/P&gt;
&lt;P&gt;&lt;FONT size="2" color="#808080"&gt;&lt;EM&gt;$(f_Format('num','add',4,3))&lt;/EM&gt;&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In this way, what we are doing is to evaluate the f_Calc variable when setting it in the f_Format. Then, f_Format only needs to care about the first parameter and the result of f_Calc.&lt;/P&gt;
&lt;P&gt;The previous way was loading all as a text, then the formula was not working because it was not understanding the pick and match parenthesis as an evaluated result and it was assigning the parameters in the wrong positions. For this reason, changing them to 5 and 6 solved partially the problem.&lt;/P&gt;
&lt;P&gt;However, this had a flaw and it is that we needed to change 5 and 6 depending if we were adding or subtracting. With these new formulas, this issue should be avoided. Also, the measure in front end is more compact and cleaner.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind Regards&lt;/P&gt;
&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2026 09:53:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Using-nested-function-with-comma-arguments/m-p/2546792#M109987</guid>
      <dc:creator>Daniel_Castella</dc:creator>
      <dc:date>2026-04-14T09:53:05Z</dc:date>
    </item>
    <item>
      <title>Re: Using nested function with comma arguments</title>
      <link>https://community.qlik.com/t5/App-Development/Using-nested-function-with-comma-arguments/m-p/2546793#M109988</link>
      <description>&lt;P&gt;Ah ok I think I understand it. The only issue with the embedding the calculation inside the format function - which is what I did initially - is I need to create one format function per calculation function. However I have several different custom calculation functions that Qlik doesnt support (for example one that does a weighted avg, one that does something else), and would like to use the same Format function for these different calculation to reduce redundancy. Hence my idea of simply using the Format function and passing it any function that returns a value (regardless of what the function does). Hope this makes sense&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 14 Apr 2026 10:02:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Using-nested-function-with-comma-arguments/m-p/2546793#M109988</guid>
      <dc:creator>johnnyjohn</dc:creator>
      <dc:date>2026-04-14T10:02:27Z</dc:date>
    </item>
    <item>
      <title>Re: Using nested function with comma arguments</title>
      <link>https://community.qlik.com/t5/App-Development/Using-nested-function-with-comma-arguments/m-p/2547374#M110034</link>
      <description>&lt;P&gt;Any ideas on how we could make that work ?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2026 12:18:56 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Using-nested-function-with-comma-arguments/m-p/2547374#M110034</guid>
      <dc:creator>johnnyjohn</dc:creator>
      <dc:date>2026-04-21T12:18:56Z</dc:date>
    </item>
    <item>
      <title>Re: Using nested function with comma arguments</title>
      <link>https://community.qlik.com/t5/App-Development/Using-nested-function-with-comma-arguments/m-p/2547396#M110038</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/109463"&gt;@johnnyjohn&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Try this expression. Basically, what we need to do is that f_Calc is calculated first and not together with f_Format. That is what the extra $ is doing, forcing f_Calc to become a number instead of the whole formula. Then, since the second part in the f_Format will be a number, it understands how to replace it in the expression:&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;FONT size="2" color="#808080"&gt;$(f_Format('num',$(=$(f_Calc('add',4,3)))))&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind Regards&lt;/P&gt;
&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2026 14:28:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Using-nested-function-with-comma-arguments/m-p/2547396#M110038</guid>
      <dc:creator>Daniel_Castella</dc:creator>
      <dc:date>2026-04-21T14:28:27Z</dc:date>
    </item>
    <item>
      <title>Re: Using nested function with comma arguments</title>
      <link>https://community.qlik.com/t5/App-Development/Using-nested-function-with-comma-arguments/m-p/2547402#M110039</link>
      <description>&lt;P&gt;Thanks for this. And what would the backend function variable be defined as ?&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2026 15:04:07 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Using-nested-function-with-comma-arguments/m-p/2547402#M110039</guid>
      <dc:creator>johnnyjohn</dc:creator>
      <dc:date>2026-04-21T15:04:07Z</dc:date>
    </item>
    <item>
      <title>Re: Using nested function with comma arguments</title>
      <link>https://community.qlik.com/t5/App-Development/Using-nested-function-with-comma-arguments/m-p/2547406#M110041</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/109463"&gt;@johnnyjohn&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Ah, no, no. You just need to use the same variables that you posted at the beginning.&lt;/P&gt;
&lt;PRE class="lia-code-sample  language-python"&gt;&lt;CODE&gt;Set f_Format = Pick(Match($1, 'num','text'), NUM($2), TEXT($2));&lt;/CODE&gt;&lt;/PRE&gt;
&lt;PRE class="lia-code-sample  language-python"&gt;&lt;CODE&gt;Set f_Calc = PICK(Match($1, 'add', 'sub'), $2 + $3, $2 - $3);&lt;/CODE&gt;&lt;/PRE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I found the way to integrate them properly in the front end expression. I'm used to split the measures in different variables. For this reason, at the beginning I was modifying them. But I just found the compact expression without needing to change them.&lt;/P&gt;
&lt;P&gt;&lt;EM&gt;&lt;FONT size="2" color="#808080"&gt;$(f_Format('num',$(=$(f_Calc('add',4,3)))))&lt;/FONT&gt;&lt;/EM&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind Regards&lt;/P&gt;
&lt;P&gt;Daniel&lt;/P&gt;</description>
      <pubDate>Tue, 21 Apr 2026 15:06:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Using-nested-function-with-comma-arguments/m-p/2547406#M110041</guid>
      <dc:creator>Daniel_Castella</dc:creator>
      <dc:date>2026-04-21T15:06:06Z</dc:date>
    </item>
  </channel>
</rss>

