<?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 could I have three differets field with specific information from Hire and leave days. in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/How-could-I-have-three-differets-field-with-specific-information/m-p/2485664#M101303</link>
    <description>&lt;P&gt;Hello folks,&lt;/P&gt;
&lt;P&gt;Hope this message fins you well, and could help me out with this matter.&lt;/P&gt;
&lt;P&gt;I stuck with app about information of employees from a any company.&lt;/P&gt;
&lt;P&gt;I would like to have all the info about when has been hired and when has been left.&lt;/P&gt;
&lt;P&gt;1. if start_date = cannonical_date = hired_date, if termination_date = cannocinal_date = left_day, '-'&lt;/P&gt;
&lt;P&gt;2. if&amp;nbsp;&lt;STRONG&gt;Month&lt;/STRONG&gt;(start_date) = &lt;STRONG&gt;Month&lt;/STRONG&gt;(cannonical_date) then hired_month, if &lt;STRONG&gt;Month&lt;/STRONG&gt;( termination_date) = &lt;STRONG&gt;month&lt;/STRONG&gt;(cannocinal_date) then hired_month, '-'&lt;/P&gt;
&lt;P&gt;3. if &lt;STRONG&gt;Year&lt;/STRONG&gt;(start_date) = &lt;STRONG&gt;Year&lt;/STRONG&gt;(cannonical_date) then hired_year, if &lt;STRONG&gt;Year&lt;/STRONG&gt;( termination_date) = &lt;STRONG&gt;Year&amp;nbsp;&lt;/STRONG&gt;(cannocinal_date) then hired_year, '-'&lt;/P&gt;
&lt;P&gt;Actually the last part of the leftmonth is wrong because it should be '-'&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="migueldfr_23_1-1728313771395.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/172595iB1AE296F55456722/image-size/medium?v=v2&amp;amp;px=400" role="button" title="migueldfr_23_1-1728313771395.png" alt="migueldfr_23_1-1728313771395.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;this is the script that I have created to retrieve the logic listed.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;// Crear el mapeo para las fechas de entrada (start_date)
person_id2start_date:
MAPPING LOAD
    person_id,
    start_date
RESIDENT hcm_workers;

// Crear el mapeo para las fechas de salida (termination_date)
person_id2termination_date:
MAPPING LOAD
    person_id,
    If(IsNull(termination_date), Today(), Date(termination_date)) as termination_date
RESIDENT hcm_workers;


DateBridge:
LOAD
    person_id &amp;amp; '-' &amp;amp; full_name as Key_person_id_full_name,
    Date(ApplyMap('person_id2start_date', person_id) + IterNo() - 1) as CanonicalDate,
    Year(ApplyMap('person_id2start_date', person_id) + IterNo() - 1) as CanonicalYear,
    Month(ApplyMap('person_id2start_date', person_id) + IterNo() - 1) as CanonicalMonth,

    // Día (hiredday o leftday)
    If(
        ApplyMap('person_id2start_date', person_id) + IterNo() - 1 = ApplyMap('person_id2start_date', person_id),
        'hiredday',
        If(
            ApplyMap('person_id2termination_date', person_id) + IterNo() - 1 = ApplyMap('person_id2termination_date', person_id),
            'leftday',
            '-'
        )
    ) as datetypedia,

    // Mes (hiredmonth o leftmonth)
    If(
        Month(ApplyMap('person_id2start_date', person_id) + IterNo() - 1) = Month(ApplyMap('person_id2start_date', person_id))
        AND Year(ApplyMap('person_id2start_date', person_id) + IterNo() - 1) = Year((ApplyMap('person_id2start_date', person_id))),
        'hiredmonth',
        If(
			Month(ApplyMap('person_id2termination_date', person_id)) = Month(ApplyMap('person_id2termination_date', person_id) + IterNo() - 1)
            AND Year(ApplyMap('person_id2termination_date', person_id)) = Year(ApplyMap('person_id2termination_date', person_id) + IterNo() - 1),
            'leftmonth',
            '-'
        )
    ) as datetypemonth,

    // Año (hiredyear o leftyear)
    If(
        Year(ApplyMap('person_id2start_date', person_id) + IterNo() - 1) = Year(ApplyMap('person_id2start_date', person_id)),
        'hiredyear',
        If(
            Year(ApplyMap('person_id2termination_date', person_id)) = Year(ApplyMap('person_id2termination_date', person_id) + IterNo() - 1),
            'leftyear',
            '-'
        )
    ) as datetypeyear


RESIDENT hcm_workers
// El ciclo debe continuar hasta el último día trabajado

WHILE ApplyMap('person_id2start_date', person_id) + IterNo() - 1 &amp;lt;= Today()
AND ApplyMap('person_id2start_date', person_id) + IterNo() - 1 &amp;lt;= ApplyMap('person_id2termination_date', person_id, Today());
&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;I would like to achieve the porpuse, but leftmont, leftyear and leftday, does not show up on my table. so I am not doing in the right way.&lt;BR /&gt;&lt;BR /&gt;I would appreciate any help&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 07 Oct 2024 15:14:13 GMT</pubDate>
    <dc:creator>migueldfr_23</dc:creator>
    <dc:date>2024-10-07T15:14:13Z</dc:date>
    <item>
      <title>How could I have three differets field with specific information from Hire and leave days.</title>
      <link>https://community.qlik.com/t5/App-Development/How-could-I-have-three-differets-field-with-specific-information/m-p/2485664#M101303</link>
      <description>&lt;P&gt;Hello folks,&lt;/P&gt;
&lt;P&gt;Hope this message fins you well, and could help me out with this matter.&lt;/P&gt;
&lt;P&gt;I stuck with app about information of employees from a any company.&lt;/P&gt;
&lt;P&gt;I would like to have all the info about when has been hired and when has been left.&lt;/P&gt;
&lt;P&gt;1. if start_date = cannonical_date = hired_date, if termination_date = cannocinal_date = left_day, '-'&lt;/P&gt;
&lt;P&gt;2. if&amp;nbsp;&lt;STRONG&gt;Month&lt;/STRONG&gt;(start_date) = &lt;STRONG&gt;Month&lt;/STRONG&gt;(cannonical_date) then hired_month, if &lt;STRONG&gt;Month&lt;/STRONG&gt;( termination_date) = &lt;STRONG&gt;month&lt;/STRONG&gt;(cannocinal_date) then hired_month, '-'&lt;/P&gt;
&lt;P&gt;3. if &lt;STRONG&gt;Year&lt;/STRONG&gt;(start_date) = &lt;STRONG&gt;Year&lt;/STRONG&gt;(cannonical_date) then hired_year, if &lt;STRONG&gt;Year&lt;/STRONG&gt;( termination_date) = &lt;STRONG&gt;Year&amp;nbsp;&lt;/STRONG&gt;(cannocinal_date) then hired_year, '-'&lt;/P&gt;
&lt;P&gt;Actually the last part of the leftmonth is wrong because it should be '-'&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="migueldfr_23_1-1728313771395.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/172595iB1AE296F55456722/image-size/medium?v=v2&amp;amp;px=400" role="button" title="migueldfr_23_1-1728313771395.png" alt="migueldfr_23_1-1728313771395.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;this is the script that I have created to retrieve the logic listed.&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;// Crear el mapeo para las fechas de entrada (start_date)
person_id2start_date:
MAPPING LOAD
    person_id,
    start_date
RESIDENT hcm_workers;

// Crear el mapeo para las fechas de salida (termination_date)
person_id2termination_date:
MAPPING LOAD
    person_id,
    If(IsNull(termination_date), Today(), Date(termination_date)) as termination_date
RESIDENT hcm_workers;


DateBridge:
LOAD
    person_id &amp;amp; '-' &amp;amp; full_name as Key_person_id_full_name,
    Date(ApplyMap('person_id2start_date', person_id) + IterNo() - 1) as CanonicalDate,
    Year(ApplyMap('person_id2start_date', person_id) + IterNo() - 1) as CanonicalYear,
    Month(ApplyMap('person_id2start_date', person_id) + IterNo() - 1) as CanonicalMonth,

    // Día (hiredday o leftday)
    If(
        ApplyMap('person_id2start_date', person_id) + IterNo() - 1 = ApplyMap('person_id2start_date', person_id),
        'hiredday',
        If(
            ApplyMap('person_id2termination_date', person_id) + IterNo() - 1 = ApplyMap('person_id2termination_date', person_id),
            'leftday',
            '-'
        )
    ) as datetypedia,

    // Mes (hiredmonth o leftmonth)
    If(
        Month(ApplyMap('person_id2start_date', person_id) + IterNo() - 1) = Month(ApplyMap('person_id2start_date', person_id))
        AND Year(ApplyMap('person_id2start_date', person_id) + IterNo() - 1) = Year((ApplyMap('person_id2start_date', person_id))),
        'hiredmonth',
        If(
			Month(ApplyMap('person_id2termination_date', person_id)) = Month(ApplyMap('person_id2termination_date', person_id) + IterNo() - 1)
            AND Year(ApplyMap('person_id2termination_date', person_id)) = Year(ApplyMap('person_id2termination_date', person_id) + IterNo() - 1),
            'leftmonth',
            '-'
        )
    ) as datetypemonth,

    // Año (hiredyear o leftyear)
    If(
        Year(ApplyMap('person_id2start_date', person_id) + IterNo() - 1) = Year(ApplyMap('person_id2start_date', person_id)),
        'hiredyear',
        If(
            Year(ApplyMap('person_id2termination_date', person_id)) = Year(ApplyMap('person_id2termination_date', person_id) + IterNo() - 1),
            'leftyear',
            '-'
        )
    ) as datetypeyear


RESIDENT hcm_workers
// El ciclo debe continuar hasta el último día trabajado

WHILE ApplyMap('person_id2start_date', person_id) + IterNo() - 1 &amp;lt;= Today()
AND ApplyMap('person_id2start_date', person_id) + IterNo() - 1 &amp;lt;= ApplyMap('person_id2termination_date', person_id, Today());
&lt;/LI-CODE&gt;
&lt;P&gt;&lt;BR /&gt;I would like to achieve the porpuse, but leftmont, leftyear and leftday, does not show up on my table. so I am not doing in the right way.&lt;BR /&gt;&lt;BR /&gt;I would appreciate any help&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Thank you&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 07 Oct 2024 15:14:13 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-could-I-have-three-differets-field-with-specific-information/m-p/2485664#M101303</guid>
      <dc:creator>migueldfr_23</dc:creator>
      <dc:date>2024-10-07T15:14:13Z</dc:date>
    </item>
    <item>
      <title>Re: How could I have three differets field with specific information from Hire and leave days.</title>
      <link>https://community.qlik.com/t5/App-Development/How-could-I-have-three-differets-field-with-specific-information/m-p/2486036#M101335</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;
&lt;P&gt;Please show the example of the raw data and the example (can be just some screenshot of excel) what do you actually want.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If you have employee start date and end date, just derivate Month and Year from there. Use Intervalmatch to "expand" the range and have your date field key for Canonical Calendar.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Intervalmatch related course:&amp;nbsp;&lt;A href="https://learning.qlik.com/enrol/index.php?id=1847" target="_blank"&gt;https://learning.qlik.com/enrol/index.php?id=1847&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;About creating the calendar:&amp;nbsp;&lt;A href="https://qlikviewcookbook.com/2015/05/better-calendar-scripts/" target="_blank"&gt;https://qlikviewcookbook.com/2015/05/better-calendar-scripts/&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;Without more info its hard to help you.&lt;/P&gt;</description>
      <pubDate>Tue, 08 Oct 2024 18:29:36 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-could-I-have-three-differets-field-with-specific-information/m-p/2486036#M101335</guid>
      <dc:creator>zar</dc:creator>
      <dc:date>2024-10-08T18:29:36Z</dc:date>
    </item>
    <item>
      <title>Re: How could I have three differets field with specific information from Hire and leave days.</title>
      <link>https://community.qlik.com/t5/App-Development/How-could-I-have-three-differets-field-with-specific-information/m-p/2486126#M101350</link>
      <description>&lt;P&gt;Good morning&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/154754"&gt;@zar&lt;/a&gt;&amp;nbsp;.&lt;BR /&gt;&lt;BR /&gt;Thank you for your response.&lt;BR /&gt;&lt;BR /&gt;I’m attaching an Excel example with the logic behind the script provided. &lt;BR /&gt;&lt;BR /&gt;Additionally, I would like to add the option to select by date or by month and compare them, depending on the key user’s preferences.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="migueldfr_23_0-1728457295276.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/172722i42D552F5107C666C/image-size/medium?v=v2&amp;amp;px=400" role="button" title="migueldfr_23_0-1728457295276.png" alt="migueldfr_23_0-1728457295276.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;The display should include:&lt;BR /&gt;&lt;BR /&gt;P1 canonical date or month&amp;nbsp;&lt;BR /&gt;P2 canonical date or month&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;Then, I’d like to compare them with a percentage showing the gain or loss.&lt;/P&gt;
&lt;P&gt;I would appreciate any help&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2024 07:08:09 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-could-I-have-three-differets-field-with-specific-information/m-p/2486126#M101350</guid>
      <dc:creator>migueldfr_23</dc:creator>
      <dc:date>2024-10-09T07:08:09Z</dc:date>
    </item>
    <item>
      <title>Re: How could I have three differets field with specific information from Hire and leave days.</title>
      <link>https://community.qlik.com/t5/App-Development/How-could-I-have-three-differets-field-with-specific-information/m-p/2486256#M101368</link>
      <description>&lt;P&gt;Few considerations:&lt;/P&gt;
&lt;P&gt;1) For comparison analysis consider use Alternate States.&lt;/P&gt;
&lt;P&gt;2) Simplify your approach, use IntervalMatch for dates, for example, or Master calendar.&lt;/P&gt;
&lt;P&gt;3) Use your master calendar fields for filtering.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;4) Create Filter pane in default and alternate state for comparison. Same for KPI. The easiest way to have it.&lt;/P&gt;
&lt;P&gt;5) Use alternate dimensions in charts to see analysis at distinct level.&lt;/P&gt;
&lt;P&gt;This is an interesting project, I highly recommend view some QCC courses related to work with dates and generation of calendars.&lt;/P&gt;
&lt;P&gt;My example view:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Captura de pantalla 2024-10-09 a las 18.41.45.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/172756i5C2C57686C6B09BF/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Captura de pantalla 2024-10-09 a las 18.41.45.png" alt="Captura de pantalla 2024-10-09 a las 18.41.45.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Expression for KPI is exactly the same for both, only changes the state they are:&lt;/P&gt;
&lt;P&gt;Expression:&amp;nbsp;Count(Distinct person_id)&lt;/P&gt;
&lt;P&gt;State for second KPI and Filters:&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Captura de pantalla 2024-10-09 a las 18.43.36.png" style="width: 400px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/172757i2F7D641A6C3A465B/image-size/medium?v=v2&amp;amp;px=400" role="button" title="Captura de pantalla 2024-10-09 a las 18.43.36.png" alt="Captura de pantalla 2024-10-09 a las 18.43.36.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;Providing the script used:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;hcm_workers:
LOAD
	person_id
    ,Date#(start_date,'YYYY-MM-DD')			as	start_date
    ,Date#(termination_date,'YYYY-MM-DD')	as	termination_date
;
LOAD * INLINE [
person_id, start_date, termination_date
Employee01,2024-08-25,2024-09-01
Employee02,2024-09-01,
Employee03,2024-08-30,2024-09-26
]
;


TEMP_ALL_POSSIBLE_DATES:
LOAD
Distinct
	start_date	AS	DATE_FOR_CALENDAR
RESIDENT
hcm_workers
;
Concatenate(TEMP_ALL_POSSIBLE_DATES)
LOAD
Distinct
	termination_date	AS	DATE_FOR_CALENDAR
RESIDENT
hcm_workers
;
Concatenate(TEMP_ALL_POSSIBLE_DATES)
LOAD
Distinct
	Date(Today(1),'YYYY-MM-DD')	AS	DATE_FOR_CALENDAR
AutoGenerate 1
;

// calendar generation https://qlikviewcookbook.com/2015/05/better-calendar-scripts/


MasterCalendar: 
Load 
 TempDate AS Date, 
 week(TempDate) As Week, 
 Year(TempDate) As Year, 
 Month(TempDate) As Month, 
 Day(TempDate) As Day, 
 'Q' &amp;amp; ceil(month(TempDate) / 3) AS Quarter, 
 Week(weekstart(TempDate)) &amp;amp; '-' &amp;amp; WeekYear(TempDate) as WeekYear, 
 WeekDay(TempDate) as WeekDay 
;

//=== Generate a temp table of dates === 
LOAD 
 date(mindate + IterNo()) AS TempDate
 ,maxdate // Used in InYearToDate() above, but not kept 
WHILE mindate + IterNo() &amp;lt;= maxdate;
//=== Get min/max dates from Field ===/
LOAD
 Min(FieldValue('DATE_FOR_CALENDAR',recno()))-1 as mindate,
 Max(FieldValue('DATE_FOR_CALENDAR', recno())) as maxdate
AUTOGENERATE FieldValueCount('DATE_FOR_CALENDAR');

drop table TEMP_ALL_POSSIBLE_DATES;

//Intervalmatch bridge (can join if dont wnt sync key)
Inner Join (hcm_workers)
IntervalMatch(Date)
LOAD
	start_date
    ,termination_date
RESIDENT
hcm_workers
;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 09 Oct 2024 16:48:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-could-I-have-three-differets-field-with-specific-information/m-p/2486256#M101368</guid>
      <dc:creator>zar</dc:creator>
      <dc:date>2024-10-09T16:48:06Z</dc:date>
    </item>
  </channel>
</rss>

