<?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 How to write an if statement with nested aggr functions in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/How-to-write-an-if-statement-with-nested-aggr-functions/m-p/1719215#M723583</link>
    <description>&lt;P&gt;I am having real trouble with the syntax of my formula. Currently in a table i have this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DaithiOK_0-1592305894558.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/35629iDEA6E4014B3F149A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DaithiOK_0-1592305894558.png" alt="DaithiOK_0-1592305894558.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;whereby i have a list of projects and the number of days since their last steering status. 0 is a default for never having had one before.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The # Projects column is my expression to limit the contents of the table and the formula is this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;if(DaysSinceLast_SteeringStatusT =0 or DaysSinceLast_SteeringStatusT &amp;gt;45,
Count(aggr(COUNT(
		{&amp;lt;
			[L2 Programme Type Code Parent] = {'xyz'}, 
			[Year] = {$(v_Max_Year)},
			ReportMonth={$(vCurrentMonth)},
			DaysSinceLast_SteeringStatusT = {"&amp;gt;45"},
		&amp;gt;} 
distinct [Project Code])
,Programme))

+
Count(aggr(COUNT(
		{&amp;lt;
			[L2 Programme Type Code Parent] = {'xyz'}, 
			[Year] = {$(v_Max_Year)},
			ReportMonth={$(vCurrentMonth)},
			DaysSinceLast_SteeringStatusT = {0},
		&amp;gt;} 
distinct [Project Code])
,Programme)))&lt;/LI-CODE&gt;&lt;P&gt;I have to aggr the count because i am rolling up child projects of xyz to L2 and 'Programme' is the level i aggregate at. I also have to include the IF statement because there are some stragglers left behind in the rollup when i use DaysSInceLast_SteeringStatusT.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I am trying to do though is to put the number 41 that you see in the table into a KPI (text box) but I can't figure out how to as I cannot use the IF statement&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;if(DaysSinceLast_SteeringStatusT =0 or DaysSinceLast_SteeringStatusT &amp;gt;45,....&lt;/LI-CODE&gt;&lt;P&gt;as it doesnt relate to anything like in the table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried doubling up on the aggr functions outside of the IF statement (below) but it doesnt work.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;=
count(
{&amp;lt;

	[L2 Programme Type Code Parent] = {'xyz'}, 
	[Year] = {$(v_Max_Year)},
	ReportMonth={$(vCurrentMonth)},
	DaysSinceLast_SteeringStatusT = {"&amp;gt;45"}
	&amp;gt;}
aggr(
if( DaysSinceLast_SteeringStatusT = 0 or DaysSinceLast_SteeringStatusT &amp;gt;45,

Count(aggr((COUNT(
			{&amp;lt;
				[L2 Programme Type Code Parent] = {'xyz'}, 
				[Year] = {$(v_Max_Year)},
				ReportMonth={$(vCurrentMonth)},
				DaysSinceLast_SteeringStatusT = {"&amp;gt;45"}	
			&amp;gt;} 
	distinct [Project Code]))
	)
,Programme))
,Programme)
distinct [Project Code])
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help translating the table formula into a formula that works in a text box would be great I'm struggling to get to grips wtih aggrs.&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 18:29:13 GMT</pubDate>
    <dc:creator>DaithiOK</dc:creator>
    <dc:date>2024-11-16T18:29:13Z</dc:date>
    <item>
      <title>How to write an if statement with nested aggr functions</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-write-an-if-statement-with-nested-aggr-functions/m-p/1719215#M723583</link>
      <description>&lt;P&gt;I am having real trouble with the syntax of my formula. Currently in a table i have this:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="DaithiOK_0-1592305894558.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/35629iDEA6E4014B3F149A/image-size/medium?v=v2&amp;amp;px=400" role="button" title="DaithiOK_0-1592305894558.png" alt="DaithiOK_0-1592305894558.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;whereby i have a list of projects and the number of days since their last steering status. 0 is a default for never having had one before.&amp;nbsp;&lt;/P&gt;&lt;P&gt;The # Projects column is my expression to limit the contents of the table and the formula is this:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;if(DaysSinceLast_SteeringStatusT =0 or DaysSinceLast_SteeringStatusT &amp;gt;45,
Count(aggr(COUNT(
		{&amp;lt;
			[L2 Programme Type Code Parent] = {'xyz'}, 
			[Year] = {$(v_Max_Year)},
			ReportMonth={$(vCurrentMonth)},
			DaysSinceLast_SteeringStatusT = {"&amp;gt;45"},
		&amp;gt;} 
distinct [Project Code])
,Programme))

+
Count(aggr(COUNT(
		{&amp;lt;
			[L2 Programme Type Code Parent] = {'xyz'}, 
			[Year] = {$(v_Max_Year)},
			ReportMonth={$(vCurrentMonth)},
			DaysSinceLast_SteeringStatusT = {0},
		&amp;gt;} 
distinct [Project Code])
,Programme)))&lt;/LI-CODE&gt;&lt;P&gt;I have to aggr the count because i am rolling up child projects of xyz to L2 and 'Programme' is the level i aggregate at. I also have to include the IF statement because there are some stragglers left behind in the rollup when i use DaysSInceLast_SteeringStatusT.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I am trying to do though is to put the number 41 that you see in the table into a KPI (text box) but I can't figure out how to as I cannot use the IF statement&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;if(DaysSinceLast_SteeringStatusT =0 or DaysSinceLast_SteeringStatusT &amp;gt;45,....&lt;/LI-CODE&gt;&lt;P&gt;as it doesnt relate to anything like in the table.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried doubling up on the aggr functions outside of the IF statement (below) but it doesnt work.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;=
count(
{&amp;lt;

	[L2 Programme Type Code Parent] = {'xyz'}, 
	[Year] = {$(v_Max_Year)},
	ReportMonth={$(vCurrentMonth)},
	DaysSinceLast_SteeringStatusT = {"&amp;gt;45"}
	&amp;gt;}
aggr(
if( DaysSinceLast_SteeringStatusT = 0 or DaysSinceLast_SteeringStatusT &amp;gt;45,

Count(aggr((COUNT(
			{&amp;lt;
				[L2 Programme Type Code Parent] = {'xyz'}, 
				[Year] = {$(v_Max_Year)},
				ReportMonth={$(vCurrentMonth)},
				DaysSinceLast_SteeringStatusT = {"&amp;gt;45"}	
			&amp;gt;} 
	distinct [Project Code]))
	)
,Programme))
,Programme)
distinct [Project Code])
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help translating the table formula into a formula that works in a text box would be great I'm struggling to get to grips wtih aggrs.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 18:29:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-write-an-if-statement-with-nested-aggr-functions/m-p/1719215#M723583</guid>
      <dc:creator>DaithiOK</dc:creator>
      <dc:date>2024-11-16T18:29:13Z</dc:date>
    </item>
    <item>
      <title>Re: How to write an if statement with nested aggr functions</title>
      <link>https://community.qlik.com/t5/QlikView/How-to-write-an-if-statement-with-nested-aggr-functions/m-p/1719273#M723584</link>
      <description>&lt;P&gt;May be you need this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Count(Aggr(
If(DaysSinceLast_SteeringStatusT = 0 or DaysSinceLast_SteeringStatusT &amp;gt; 45,
Count({&amp;lt;
	[L2 Programme Type Code Parent] = {'xyz'}, 
	[Year] = {$(v_Max_Year)},
	ReportMonth={$(vCurrentMonth)},
	DaysSinceLast_SteeringStatusT = {"&amp;gt;45"}&amp;gt;} 
DISTINCT [Project Code])
Count({&amp;lt;
	[L2 Programme Type Code Parent] = {'xyz'}, 
	[Year] = {$(v_Max_Year)},
	ReportMonth={$(vCurrentMonth)},
	DaysSinceLast_SteeringStatusT = {0}&amp;gt;} 
DISTINCT [Project Code]))
, Programme))&lt;/LI-CODE&gt;&lt;P&gt;But I feel like you really need a Sum for the outer aggregation like this&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Sum(Aggr(
If(DaysSinceLast_SteeringStatusT = 0 or DaysSinceLast_SteeringStatusT &amp;gt; 45,
Count({&amp;lt;
	[L2 Programme Type Code Parent] = {'xyz'}, 
	[Year] = {$(v_Max_Year)},
	ReportMonth={$(vCurrentMonth)},
	DaysSinceLast_SteeringStatusT = {"&amp;gt;45"}&amp;gt;} 
DISTINCT [Project Code])
Count({&amp;lt;
	[L2 Programme Type Code Parent] = {'xyz'}, 
	[Year] = {$(v_Max_Year)},
	ReportMonth={$(vCurrentMonth)},
	DaysSinceLast_SteeringStatusT = {0}&amp;gt;} 
DISTINCT [Project Code]))
, Programme))&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 16 Jun 2020 13:33:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/How-to-write-an-if-statement-with-nested-aggr-functions/m-p/1719273#M723584</guid>
      <dc:creator>sunny_talwar</dc:creator>
      <dc:date>2020-06-16T13:33:05Z</dc:date>
    </item>
  </channel>
</rss>

