<?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 Create a flag based on an aggregate value in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Create-a-flag-based-on-an-aggregate-value/m-p/1538144#M38834</link>
    <description>&lt;P&gt;Hi experts,&lt;/P&gt;&lt;P&gt;I want a flag to see if an employee is active or not. An employee is active if in the max date there is a '3' in the S column. The problem is that in some rows, an employee has the vale '3' or '0' in the S column and the same date.&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="Employee.png" style="width: 596px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/4989iF7B7EFCF44D6F538/image-size/large?v=v2&amp;amp;px=999" role="button" title="Employee.png" alt="Employee.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I.E: User 8, 9 and 13 are active users, but 90 shouldn't be.&lt;/P&gt;&lt;P&gt;This is the script :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;[Actions]:
LOAD 
	[Person ID] as "User Sys ID",
	[Pers.No.],
	Date([Start Date] ) AS [Start Date],
	Date([End Date] ) AS [End Date],
        Year([Start Date]) as "Year",
        Month([Start Date]) as "Month",
	[Act.],
	[ActR] as [Action Reason],
	[S],
	[Position],
	[CoCd],
	[PA],
// 	[PSubarea],
	[PSA]
 FROM [lib://qlikid_danimelo1/Actions.XLSX]
(ooxml, embedded labels, table is Sheet1);
Left Join

//[Termination Action Reasons]:
LOAD [Type] as [Action Reason],
	[Termination Reason],
	[Voluntary/involuntary]
 FROM [lib://qlikid_danimelo1/Actions and reasons.XLSX]
(ooxml, embedded labels, table is [Termination Action Reasons]);

[EMax]:
Load
    "User Sys ID" as "E.User",
    Date(Max("Start Date")) as "FechaMax",
    if(S = 3, 'Activo') as "flag"    
    Resident Actions
    Group By "User Sys ID", S;   
    
Final:
Load 
      "E.User" as "User Sys ID",	 
     "flag" as "Flag"
resident EMax
Where "flag"='Activo';

join (Actions)
Load "User Sys ID",
	 "Flag"
Resident Final;

Drop Tables Final, EMax;&lt;/PRE&gt;&lt;P&gt;I'm attaching an Excel file with the data. Any idea what I'm missing?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 06:42:18 GMT</pubDate>
    <dc:creator>danimelo1</dc:creator>
    <dc:date>2024-11-16T06:42:18Z</dc:date>
    <item>
      <title>Create a flag based on an aggregate value</title>
      <link>https://community.qlik.com/t5/App-Development/Create-a-flag-based-on-an-aggregate-value/m-p/1538144#M38834</link>
      <description>&lt;P&gt;Hi experts,&lt;/P&gt;&lt;P&gt;I want a flag to see if an employee is active or not. An employee is active if in the max date there is a '3' in the S column. The problem is that in some rows, an employee has the vale '3' or '0' in the S column and the same date.&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="Employee.png" style="width: 596px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/4989iF7B7EFCF44D6F538/image-size/large?v=v2&amp;amp;px=999" role="button" title="Employee.png" alt="Employee.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;I.E: User 8, 9 and 13 are active users, but 90 shouldn't be.&lt;/P&gt;&lt;P&gt;This is the script :&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;[Actions]:
LOAD 
	[Person ID] as "User Sys ID",
	[Pers.No.],
	Date([Start Date] ) AS [Start Date],
	Date([End Date] ) AS [End Date],
        Year([Start Date]) as "Year",
        Month([Start Date]) as "Month",
	[Act.],
	[ActR] as [Action Reason],
	[S],
	[Position],
	[CoCd],
	[PA],
// 	[PSubarea],
	[PSA]
 FROM [lib://qlikid_danimelo1/Actions.XLSX]
(ooxml, embedded labels, table is Sheet1);
Left Join

//[Termination Action Reasons]:
LOAD [Type] as [Action Reason],
	[Termination Reason],
	[Voluntary/involuntary]
 FROM [lib://qlikid_danimelo1/Actions and reasons.XLSX]
(ooxml, embedded labels, table is [Termination Action Reasons]);

[EMax]:
Load
    "User Sys ID" as "E.User",
    Date(Max("Start Date")) as "FechaMax",
    if(S = 3, 'Activo') as "flag"    
    Resident Actions
    Group By "User Sys ID", S;   
    
Final:
Load 
      "E.User" as "User Sys ID",	 
     "flag" as "Flag"
resident EMax
Where "flag"='Activo';

join (Actions)
Load "User Sys ID",
	 "Flag"
Resident Final;

Drop Tables Final, EMax;&lt;/PRE&gt;&lt;P&gt;I'm attaching an Excel file with the data. Any idea what I'm missing?&lt;/P&gt;&lt;P&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 06:42:18 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Create-a-flag-based-on-an-aggregate-value/m-p/1538144#M38834</guid>
      <dc:creator>danimelo1</dc:creator>
      <dc:date>2024-11-16T06:42:18Z</dc:date>
    </item>
    <item>
      <title>Re: Create a flag based on an aggregate value</title>
      <link>https://community.qlik.com/t5/App-Development/Create-a-flag-based-on-an-aggregate-value/m-p/1538156#M38836</link>
      <description>&lt;P&gt;How about this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[EMax]:&lt;BR /&gt;Load&lt;BR /&gt;"User Sys ID" as "E.User",&lt;BR /&gt;Date(Max("Start Date")) as "FechaMax"&lt;BR /&gt;Resident Actions Group By "User Sys ID";&lt;BR /&gt;Inner Join&lt;BR /&gt;Load&lt;BR /&gt;"User Sys ID" as "E.User",&lt;BR /&gt;"Start Date" as "FechaMax",&lt;BR /&gt;S&lt;BR /&gt;Resident Actions;&lt;BR /&gt;&lt;BR /&gt;Final:&lt;BR /&gt;Load&lt;BR /&gt;"E.User" as "User Sys ID",&lt;BR /&gt;'Activo' as "Flag"&lt;BR /&gt;resident EMax&lt;BR /&gt;Where S = 3;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 31 Jan 2019 23:03:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Create-a-flag-based-on-an-aggregate-value/m-p/1538156#M38836</guid>
      <dc:creator>jwjackso</dc:creator>
      <dc:date>2019-01-31T23:03:13Z</dc:date>
    </item>
    <item>
      <title>Re: Create a flag based on an aggregate value</title>
      <link>https://community.qlik.com/t5/App-Development/Create-a-flag-based-on-an-aggregate-value/m-p/1538584#M38885</link>
      <description>&lt;P&gt;Nop, i tried that but it's not working.&lt;/P&gt;</description>
      <pubDate>Fri, 01 Feb 2019 16:47:02 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Create-a-flag-based-on-an-aggregate-value/m-p/1538584#M38885</guid>
      <dc:creator>danimelo1</dc:creator>
      <dc:date>2019-02-01T16:47:02Z</dc:date>
    </item>
    <item>
      <title>Re: Create a flag based on an aggregate value</title>
      <link>https://community.qlik.com/t5/App-Development/Create-a-flag-based-on-an-aggregate-value/m-p/1538664#M38891</link>
      <description>&lt;P&gt;Below is the load script that I tested:&lt;/P&gt;&lt;P&gt;Actions:&lt;BR /&gt;LOAD * Inline [&lt;BR /&gt;"User Sys ID","Start Date",S&lt;BR /&gt;8,1/24/2014,0&lt;BR /&gt;8,1/24/2014,3&lt;BR /&gt;9,7/1/2013,3&lt;BR /&gt;9,6/12/2016,1&lt;BR /&gt;9,12/10/2016,3&lt;BR /&gt;13,5/1/2014,3&lt;BR /&gt;13,7/1/2015,3&lt;BR /&gt;13,11/1/2015,3&lt;BR /&gt;13,11/25/2015,3&lt;BR /&gt;13,7/1/2016,0&lt;BR /&gt;13,7/1/2016,3&lt;BR /&gt;90,1/1/2014,3&lt;BR /&gt;90,4/10/2017,0&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;[EMax]:&lt;BR /&gt;Load&lt;BR /&gt;"User Sys ID" as "E.User",&lt;BR /&gt;Date(Max([Start Date])) as FechaMax&lt;BR /&gt;Resident Actions&lt;BR /&gt;Group By "User Sys ID";&lt;BR /&gt;Inner Join&lt;BR /&gt;LOAD "User Sys ID" as "E.User",&lt;BR /&gt;[Start Date] as FechaMax,&lt;BR /&gt;S&lt;BR /&gt;Resident Actions;&lt;/P&gt;&lt;P&gt;Final:&lt;BR /&gt;Load&lt;BR /&gt;"E.User" as "User Sys ID",&lt;BR /&gt;'Activo' as "Flag"&lt;BR /&gt;resident EMax&lt;BR /&gt;Where S = 3;&lt;/P&gt;&lt;P&gt;drop Table Actions;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The results are below:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Results" style="width: 564px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/5068iD3E48F3BEBE64E30/image-size/large?v=v2&amp;amp;px=999" role="button" title="AggregateValueTest.PNG" alt="Results" /&gt;&lt;span class="lia-inline-image-caption" onclick="event.preventDefault();"&gt;Results&lt;/span&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Are you getting different results for the flag value?&lt;/P&gt;</description>
      <pubDate>Fri, 01 Feb 2019 22:50:42 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Create-a-flag-based-on-an-aggregate-value/m-p/1538664#M38891</guid>
      <dc:creator>jwjackso</dc:creator>
      <dc:date>2019-02-01T22:50:42Z</dc:date>
    </item>
  </channel>
</rss>

