<?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 Subtract values for time between 6 pm and 8 am everyday in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Subtract-values-for-time-between-6-pm-and-8-am-everyday/m-p/2495518#M102544</link>
    <description>&lt;P&gt;Hello, I have a script which loads a simple table with data on help desk tickets.&lt;/P&gt;
&lt;P&gt;In this table, there's a column with data corresponding to the duration of a ticket, calculated from the creation date, to the last update for each row. Accordingly, I only want to get information for when the ticket is closed entirely, so I get the final duration. However, there is an issue, for example if the ticket is opened at 4pm, and closed the second day at 10am, the duration will take into account also the time after 6pm and up to 8am. But the helpdesk only works within 8am-6pm, so I shouldn't calculate that.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I fix this by using qlik load editro script? Here is what I am loading rn&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;LOAD HIST_ID, 
	HIST_TicketID as TKT_ID, 
	HIST_TicketRow, 
    HIST_Date, 
	HIST_RowTypeID, 
	HIST_RowType, 
	HIST_FromID, 
	HIST_ToID, 
	HIST_ResourceID, 
	HIST_AccountID, 
	HIST_ContactID, 
	HIST_TicketTypeID, 
	HIST_TicketStatusID, 
	HIST_TicketPriorityID, 
	HIST_TicketUrgencyID, 
	HIST_TicketGroupID, 
	HIST_TicketResourceID, 
	HIST_AdditionalInfo
    HIST_Workhourminutes;
    
[TicketsHistory]:
SELECT "HIST_ID",
	"HIST_TicketID",
	"HIST_TicketRow",
    "HIST_Date",
	"HIST_RowTypeID",
	"HIST_RowType",
	"HIST_FromID",
	"HIST_ToID",
	"HIST_ResourceID",
	"HIST_AccountID",
	"HIST_ContactID",
	"HIST_TicketTypeID",
	"HIST_TicketStatusID",
	"HIST_TicketPriorityID",
	"HIST_TicketUrgencyID",
	"HIST_TicketGroupID",
	"HIST_TicketResourceID",
	"HIST_AdditionalInfo",
    "HIST_Workhourminutes"
FROM TicketsHistory
WHERE [HIST_TicketGroupID] = 'G7C';

MaxTicketRow:
LOAD
    TKT_ID,
    MAX(HIST_TicketRow) AS MaxTicketRow
RESIDENT TicketsHistory
GROUP BY TKT_ID;

LEFT JOIN (TicketsHistory)
LOAD
    TKT_ID,
    MaxTicketRow
RESIDENT MaxTicketRow;

TicketsHistoryMax:
LOAD *,
    IF(HIST_TicketRow = MaxTicketRow, HIST_Workhourminutes, 0) AS Final_Workhours
RESIDENT TicketsHistory;

DROP TABLE TicketsHistory;
DROP TABLE MaxTicketRow;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So ideally, this end up like this:&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="25%" height="25px"&gt;TKT_ID&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;HIST_Date&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;HIST_Workhourminutes&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;Final_Workhours&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="25px"&gt;103C&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;2024-10-13 16:00:30.690&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;0&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="25px"&gt;103C&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;2024-10-14 10:00:30.690&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;1080&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;240&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is a simplistic example. The Final_Workhours is 240 because its only the time passed between 4pm and 6pm and then 8am to 10am&lt;/P&gt;</description>
    <pubDate>Mon, 02 Dec 2024 11:14:35 GMT</pubDate>
    <dc:creator>alespooletto</dc:creator>
    <dc:date>2024-12-02T11:14:35Z</dc:date>
    <item>
      <title>Subtract values for time between 6 pm and 8 am everyday</title>
      <link>https://community.qlik.com/t5/App-Development/Subtract-values-for-time-between-6-pm-and-8-am-everyday/m-p/2495518#M102544</link>
      <description>&lt;P&gt;Hello, I have a script which loads a simple table with data on help desk tickets.&lt;/P&gt;
&lt;P&gt;In this table, there's a column with data corresponding to the duration of a ticket, calculated from the creation date, to the last update for each row. Accordingly, I only want to get information for when the ticket is closed entirely, so I get the final duration. However, there is an issue, for example if the ticket is opened at 4pm, and closed the second day at 10am, the duration will take into account also the time after 6pm and up to 8am. But the helpdesk only works within 8am-6pm, so I shouldn't calculate that.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;How can I fix this by using qlik load editro script? Here is what I am loading rn&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;LOAD HIST_ID, 
	HIST_TicketID as TKT_ID, 
	HIST_TicketRow, 
    HIST_Date, 
	HIST_RowTypeID, 
	HIST_RowType, 
	HIST_FromID, 
	HIST_ToID, 
	HIST_ResourceID, 
	HIST_AccountID, 
	HIST_ContactID, 
	HIST_TicketTypeID, 
	HIST_TicketStatusID, 
	HIST_TicketPriorityID, 
	HIST_TicketUrgencyID, 
	HIST_TicketGroupID, 
	HIST_TicketResourceID, 
	HIST_AdditionalInfo
    HIST_Workhourminutes;
    
[TicketsHistory]:
SELECT "HIST_ID",
	"HIST_TicketID",
	"HIST_TicketRow",
    "HIST_Date",
	"HIST_RowTypeID",
	"HIST_RowType",
	"HIST_FromID",
	"HIST_ToID",
	"HIST_ResourceID",
	"HIST_AccountID",
	"HIST_ContactID",
	"HIST_TicketTypeID",
	"HIST_TicketStatusID",
	"HIST_TicketPriorityID",
	"HIST_TicketUrgencyID",
	"HIST_TicketGroupID",
	"HIST_TicketResourceID",
	"HIST_AdditionalInfo",
    "HIST_Workhourminutes"
FROM TicketsHistory
WHERE [HIST_TicketGroupID] = 'G7C';

MaxTicketRow:
LOAD
    TKT_ID,
    MAX(HIST_TicketRow) AS MaxTicketRow
RESIDENT TicketsHistory
GROUP BY TKT_ID;

LEFT JOIN (TicketsHistory)
LOAD
    TKT_ID,
    MaxTicketRow
RESIDENT MaxTicketRow;

TicketsHistoryMax:
LOAD *,
    IF(HIST_TicketRow = MaxTicketRow, HIST_Workhourminutes, 0) AS Final_Workhours
RESIDENT TicketsHistory;

DROP TABLE TicketsHistory;
DROP TABLE MaxTicketRow;&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;So ideally, this end up like this:&amp;nbsp;&lt;/P&gt;
&lt;TABLE border="1" width="100%"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="25%" height="25px"&gt;TKT_ID&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;HIST_Date&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;HIST_Workhourminutes&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;Final_Workhours&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="25px"&gt;103C&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;2024-10-13 16:00:30.690&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;0&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;0&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="25%" height="25px"&gt;103C&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;2024-10-14 10:00:30.690&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;1080&lt;/TD&gt;
&lt;TD width="25%" height="25px"&gt;240&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This is a simplistic example. The Final_Workhours is 240 because its only the time passed between 4pm and 6pm and then 8am to 10am&lt;/P&gt;</description>
      <pubDate>Mon, 02 Dec 2024 11:14:35 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Subtract-values-for-time-between-6-pm-and-8-am-everyday/m-p/2495518#M102544</guid>
      <dc:creator>alespooletto</dc:creator>
      <dc:date>2024-12-02T11:14:35Z</dc:date>
    </item>
    <item>
      <title>Re: Subtract values for time between 6 pm and 8 am everyday</title>
      <link>https://community.qlik.com/t5/App-Development/Subtract-values-for-time-between-6-pm-and-8-am-everyday/m-p/2496052#M102626</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/253882"&gt;@alespooletto&lt;/a&gt;&amp;nbsp;,i found these inside Qlik Community :&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.qlik.com/t5/QlikView-App-Dev/Duration-Business-hours/td-p/1241438" target="_blank"&gt;https://community.qlik.com/t5/QlikView-App-Dev/Duration-Business-hours/td-p/1241438&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://community.qlik.com/t5/QlikView-App-Dev/Working-hours-only/td-p/388475" target="_blank"&gt;https://community.qlik.com/t5/QlikView-App-Dev/Working-hours-only/td-p/388475&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 04 Dec 2024 18:27:40 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Subtract-values-for-time-between-6-pm-and-8-am-everyday/m-p/2496052#M102626</guid>
      <dc:creator>QFabian</dc:creator>
      <dc:date>2024-12-04T18:27:40Z</dc:date>
    </item>
    <item>
      <title>Re: Subtract values for time between 6 pm and 8 am everyday</title>
      <link>https://community.qlik.com/t5/App-Development/Subtract-values-for-time-between-6-pm-and-8-am-everyday/m-p/2496068#M102628</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.qlik.com/t5/user/viewprofilepage/user-id/253882"&gt;@alespooletto&lt;/a&gt;&amp;nbsp;, try this example, it just generate the valid working hours to sum them&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV&gt;Aux:&lt;/DIV&gt;
&lt;DIV&gt;Load * INLINE [&lt;/DIV&gt;
&lt;DIV&gt;Ticket, Start, End&lt;/DIV&gt;
&lt;DIV&gt;103C, 2024-10-13 16:00:30.690, 2024-10-14 10:00:30.690&lt;/DIV&gt;
&lt;DIV&gt;];&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;Let vRows = NoOfRows('Aux') - 1;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;For vRow = 0 to $(vRows)&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; Let vTicket = peek('Ticket', $(vRow), 'Aux');&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; Let vStartHour = hour((peek('End', $(vRow), 'Aux');&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; Let vHours = ceil((peek('End', $(vRow), 'Aux') - peek('Start', $(vRow), 'Aux')) * 24);&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; Data:&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; Load distinct&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; '$(vTicket)' as Ticket,&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; timestamp(peek('Start', $(vRow), 'Aux') + ((1/24) * (recno()-1)), 'DD-MM-YYYY hh:mm') as DateTime,&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; subfield(hour(peek('Start', $(vRow), 'Aux') + ((1/24) * (recno()-1))), ':', 1) as HourIndex,&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; if((subfield(hour(peek('Start', $(vRow), 'Aux') + ((1/24) * (recno()-1))), ':', 1) &amp;gt;= 8 and&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; subfield(hour(peek('Start', $(vRow), 'Aux') + ((1/24) * (recno()-1))), ':', 1) &amp;lt;= 18)&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; , 1) as HourSum,&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; if((subfield(hour(peek('Start', $(vRow), 'Aux') + ((1/24) * (recno()-1))), ':', 1) &amp;gt;= 8 and&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; subfield(hour(peek('Start', $(vRow), 'Aux') + ((1/24) * (recno()-1))), ':', 1) &amp;lt;= 18)&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; , 'V') as Type&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt; AutoGenerate($(vHours));&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;Next&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;It adds every hour classifying it according to defined working hours :&lt;/DIV&gt;
&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;
&lt;DIV&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="QFabian_2-1733341783599.png" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/175210iB784CE7A27FBB5C1/image-size/large?v=v2&amp;amp;px=999" role="button" title="QFabian_2-1733341783599.png" alt="QFabian_2-1733341783599.png" /&gt;&lt;/span&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
check the atached QVF with the entire exercise&lt;BR /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;/DIV&gt;</description>
      <pubDate>Wed, 04 Dec 2024 19:52:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Subtract-values-for-time-between-6-pm-and-8-am-everyday/m-p/2496068#M102628</guid>
      <dc:creator>QFabian</dc:creator>
      <dc:date>2024-12-04T19:52:24Z</dc:date>
    </item>
  </channel>
</rss>

