<?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: How to derive measure only the specific month that falls under range. in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/How-to-derive-measure-only-the-specific-month-that-falls-under/m-p/2487240#M101492</link>
    <description>&lt;P&gt;&amp;nbsp;Hi - i wouldnt prefer this particular view but if your requiremnt is to show the one like above:&lt;/P&gt;
&lt;P&gt;Try the below code in your script, its a bit lengthy though:&lt;/P&gt;
&lt;P&gt;//Load original Data&lt;BR /&gt;Data:&lt;BR /&gt;Load Rowno() as Key, *;&lt;BR /&gt;LOAD * INLINE [ &lt;BR /&gt;Change_Date, Report_Date, Total_Value&lt;BR /&gt;31-Dec-2024, 01-Sep-2024, 135402.96&lt;BR /&gt;];&lt;/P&gt;
&lt;P&gt;// Fetch the Min/max of the DateRange&lt;BR /&gt;// Although this step is not needed, you directly do the 'Peek' step&lt;BR /&gt;Date_Temp:&lt;BR /&gt;//LOAD Date(MonthStart(Date#(Change_Date, 'DD-MMM-YYYY')), 'DD-MMM-YYYY') as Month_Start_Date&lt;BR /&gt;//RESIDENT Data;&lt;BR /&gt;LOAD Date(MonthStart(Date#(Report_Date, 'DD-MMM-YYYY')), 'DD-MMM-YYYY') as Month_Start_Date&lt;BR /&gt;RESIDENT Data;&lt;/P&gt;
&lt;P&gt;MinMax:&lt;BR /&gt;Load Min(Month_Start_Date) as MinDate,&lt;BR /&gt;Max(Month_Start_Date) as MaxDate&lt;BR /&gt;Resident Date_Temp;&lt;/P&gt;
&lt;P&gt;Let vMinDate = Peek('MinDate',0,'Min_Max');&lt;BR /&gt;// Let vMinDateMonth =Month($(vMinDate));&lt;BR /&gt;// Let vMinDateYear =Year($(vMinDate));&lt;BR /&gt;&lt;BR /&gt;//Generate 10 months and join it the 'Data' Table&lt;BR /&gt;left join(Data)&lt;BR /&gt;ten_Months:&lt;BR /&gt;Load MakeDate, Month(MakeDate) &amp;amp; '-' &amp;amp; Year(MakeDate) as Month_Year;&lt;BR /&gt;Load &lt;BR /&gt;Date(AddMonths($(vMinDate), IterNo()-1), 'YYYY-MM-DD') as MakeDate&lt;BR /&gt;AutoGenerate 1&lt;BR /&gt;While IterNo() &amp;lt;= 10;&lt;BR /&gt;drop tables Date_Temp, MinMax;&lt;/P&gt;
&lt;P&gt;//Now find the Months that needs to be populated with divided Total_value&lt;BR /&gt;Data_Temp:&lt;BR /&gt;Load *,&lt;BR /&gt;If(Date#(MakeDate, 'YYYY-MM-DD') &amp;gt;= Date#(Report_Date,'DD-MMM-YYYY') and &lt;BR /&gt;Date#(MakeDate, 'YYYY-MM-DD') &amp;lt;= Date#(Change_Date,'DD-MMM-YYYY'), 1, 0) as InRange&lt;BR /&gt;Resident Data;&lt;BR /&gt;drop table Data;&lt;/P&gt;
&lt;P&gt;// Create a table to count the total number of months in range&lt;BR /&gt;// you cannot directly use Sum() or aggregation functions in a Let statement because Qlik executes Let statements at script runtime, &lt;BR /&gt;// whereas Sum() is evaluated in the data model (chart-level or table-level functions). &lt;BR /&gt;// To achieve the desired result, you need to use Peek() to retrieve the result from the table after the calculation.&lt;BR /&gt;TempSum:&lt;BR /&gt;LOAD &lt;BR /&gt;Sum(InRange) as NumMonthsInRange&lt;BR /&gt;RESIDENT Data_Temp;&lt;/P&gt;
&lt;P&gt;// Peek the calculated value from the table into a variable&lt;BR /&gt;Let vNumMonthsInRange = Peek('NumMonthsInRange', 0, 'TempSum');&lt;BR /&gt;DROP TABLE TempSum;&lt;/P&gt;
&lt;P&gt;// Load the final data, distributing Total_Value across the months&lt;BR /&gt;Split_Data:&lt;BR /&gt;LOAD Key, &lt;BR /&gt;Month_Year,&lt;BR /&gt;If(InRange = 1, Total_Value / $(vNumMonthsInRange), 0) as Div_Value&lt;BR /&gt;RESIDENT Data_Temp; // Generate one record for each month in range&lt;BR /&gt;drop fields Month_Year, MakeDate, InRange from Data_Temp;&lt;/P&gt;
&lt;P&gt;//Now load the distinct row, as ts generated duplicated rows column&lt;BR /&gt;NoConcatenate&lt;BR /&gt;Data:&lt;BR /&gt;Load Distinct *&lt;BR /&gt;Resident Data_Temp;&lt;BR /&gt;drop table Data_Temp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;//Prepare the final view table&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;//Let vFieldName = Peek('Month_Year',0,'Split_Data');&lt;BR /&gt;//Let vFieldValue = Peek('Div_Value',0,'Split_Data');&lt;BR /&gt;//&lt;BR /&gt;//join(Data)&lt;BR /&gt;//Load distinct Key,&lt;BR /&gt;// $(vFieldValue) as "$(vFieldName)"&lt;BR /&gt;//Resident Split_Data;&lt;/P&gt;
&lt;P&gt;for i = 0 to NoOfRows('Split_Data') - 1&lt;/P&gt;
&lt;P&gt;// Get the Month_Year field name and Div_Value for the current row&lt;BR /&gt;Let vFieldName = Peek('Month_Year', i, 'Split_Data');&lt;BR /&gt;Let vFieldValue = Peek('Div_Value', i, 'Split_Data');&lt;BR /&gt;&lt;BR /&gt;// Join to the Data table&lt;BR /&gt;JOIN (Data) // Make sure to join to the Data table&lt;BR /&gt;LOAD DISTINCT &lt;BR /&gt;Key, // Keep the existing Key to join on&lt;BR /&gt;$(vFieldValue) as [$(vFieldName)] // Create a new field with the dynamic name&lt;BR /&gt;RESIDENT Split_Data;&lt;/P&gt;
&lt;P&gt;next;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Drop table Split_Data;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2485966 - Derive measure for the months that fall in a date Range.PNG" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/172988i85BA7D5BD4257D0A/image-size/large?v=v2&amp;amp;px=999" role="button" title="2485966 - Derive measure for the months that fall in a date Range.PNG" alt="2485966 - Derive measure for the months that fall in a date Range.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 16 Oct 2024 02:13:37 GMT</pubDate>
    <dc:creator>Qrishna</dc:creator>
    <dc:date>2024-10-16T02:13:37Z</dc:date>
    <item>
      <title>How to derive measure only the specific month that falls under range.</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-derive-measure-only-the-specific-month-that-falls-under/m-p/2487119#M101464</link>
      <description>&lt;P&gt;hello Qlik experts,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I looking for the solution to implement below in qlik. I have Report date and change date, total_value fields in my DM. &amp;nbsp;&lt;/P&gt;
&lt;P&gt;I need derive 10 months based on report month and total value will be divided and show only those months those falls between Change month and Report month.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;would some one please help me on this..?&lt;/P&gt;
&lt;TABLE width="925"&gt;
&lt;TBODY&gt;
&lt;TR&gt;
&lt;TD width="64"&gt;Change_ Date&lt;/TD&gt;
&lt;TD width="64"&gt;Report_Date&lt;/TD&gt;
&lt;TD width="157"&gt;Total_value&lt;/TD&gt;
&lt;TD width="64"&gt;Sep-24&lt;/TD&gt;
&lt;TD width="64"&gt;Oct-24&lt;/TD&gt;
&lt;TD width="64"&gt;Nov-24&lt;/TD&gt;
&lt;TD width="64"&gt;Dec-24&lt;/TD&gt;
&lt;TD width="64"&gt;Jan-25&lt;/TD&gt;
&lt;TD width="64"&gt;Feb-25&lt;/TD&gt;
&lt;TD width="64"&gt;Mar-25&lt;/TD&gt;
&lt;TD width="64"&gt;Apr-25&lt;/TD&gt;
&lt;TD width="64"&gt;May-25&lt;/TD&gt;
&lt;TD width="64"&gt;Jun-25&lt;/TD&gt;
&lt;/TR&gt;
&lt;TR&gt;
&lt;TD width="64"&gt;31-Dec-2024&lt;/TD&gt;
&lt;TD width="64"&gt;01-Sep-2024&lt;/TD&gt;
&lt;TD width="157"&gt;135402.96&lt;/TD&gt;
&lt;TD width="64"&gt;33850.74&lt;/TD&gt;
&lt;TD width="64"&gt;33850.74&lt;/TD&gt;
&lt;TD width="64"&gt;33850.74&lt;/TD&gt;
&lt;TD width="64"&gt;33850.74&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;
&lt;/TR&gt;
&lt;/TBODY&gt;
&lt;/TABLE&gt;</description>
      <pubDate>Tue, 15 Oct 2024 14:02:58 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-derive-measure-only-the-specific-month-that-falls-under/m-p/2487119#M101464</guid>
      <dc:creator>Raya</dc:creator>
      <dc:date>2024-10-15T14:02:58Z</dc:date>
    </item>
    <item>
      <title>Re: How to derive measure only the specific month that falls under range.</title>
      <link>https://community.qlik.com/t5/App-Development/How-to-derive-measure-only-the-specific-month-that-falls-under/m-p/2487240#M101492</link>
      <description>&lt;P&gt;&amp;nbsp;Hi - i wouldnt prefer this particular view but if your requiremnt is to show the one like above:&lt;/P&gt;
&lt;P&gt;Try the below code in your script, its a bit lengthy though:&lt;/P&gt;
&lt;P&gt;//Load original Data&lt;BR /&gt;Data:&lt;BR /&gt;Load Rowno() as Key, *;&lt;BR /&gt;LOAD * INLINE [ &lt;BR /&gt;Change_Date, Report_Date, Total_Value&lt;BR /&gt;31-Dec-2024, 01-Sep-2024, 135402.96&lt;BR /&gt;];&lt;/P&gt;
&lt;P&gt;// Fetch the Min/max of the DateRange&lt;BR /&gt;// Although this step is not needed, you directly do the 'Peek' step&lt;BR /&gt;Date_Temp:&lt;BR /&gt;//LOAD Date(MonthStart(Date#(Change_Date, 'DD-MMM-YYYY')), 'DD-MMM-YYYY') as Month_Start_Date&lt;BR /&gt;//RESIDENT Data;&lt;BR /&gt;LOAD Date(MonthStart(Date#(Report_Date, 'DD-MMM-YYYY')), 'DD-MMM-YYYY') as Month_Start_Date&lt;BR /&gt;RESIDENT Data;&lt;/P&gt;
&lt;P&gt;MinMax:&lt;BR /&gt;Load Min(Month_Start_Date) as MinDate,&lt;BR /&gt;Max(Month_Start_Date) as MaxDate&lt;BR /&gt;Resident Date_Temp;&lt;/P&gt;
&lt;P&gt;Let vMinDate = Peek('MinDate',0,'Min_Max');&lt;BR /&gt;// Let vMinDateMonth =Month($(vMinDate));&lt;BR /&gt;// Let vMinDateYear =Year($(vMinDate));&lt;BR /&gt;&lt;BR /&gt;//Generate 10 months and join it the 'Data' Table&lt;BR /&gt;left join(Data)&lt;BR /&gt;ten_Months:&lt;BR /&gt;Load MakeDate, Month(MakeDate) &amp;amp; '-' &amp;amp; Year(MakeDate) as Month_Year;&lt;BR /&gt;Load &lt;BR /&gt;Date(AddMonths($(vMinDate), IterNo()-1), 'YYYY-MM-DD') as MakeDate&lt;BR /&gt;AutoGenerate 1&lt;BR /&gt;While IterNo() &amp;lt;= 10;&lt;BR /&gt;drop tables Date_Temp, MinMax;&lt;/P&gt;
&lt;P&gt;//Now find the Months that needs to be populated with divided Total_value&lt;BR /&gt;Data_Temp:&lt;BR /&gt;Load *,&lt;BR /&gt;If(Date#(MakeDate, 'YYYY-MM-DD') &amp;gt;= Date#(Report_Date,'DD-MMM-YYYY') and &lt;BR /&gt;Date#(MakeDate, 'YYYY-MM-DD') &amp;lt;= Date#(Change_Date,'DD-MMM-YYYY'), 1, 0) as InRange&lt;BR /&gt;Resident Data;&lt;BR /&gt;drop table Data;&lt;/P&gt;
&lt;P&gt;// Create a table to count the total number of months in range&lt;BR /&gt;// you cannot directly use Sum() or aggregation functions in a Let statement because Qlik executes Let statements at script runtime, &lt;BR /&gt;// whereas Sum() is evaluated in the data model (chart-level or table-level functions). &lt;BR /&gt;// To achieve the desired result, you need to use Peek() to retrieve the result from the table after the calculation.&lt;BR /&gt;TempSum:&lt;BR /&gt;LOAD &lt;BR /&gt;Sum(InRange) as NumMonthsInRange&lt;BR /&gt;RESIDENT Data_Temp;&lt;/P&gt;
&lt;P&gt;// Peek the calculated value from the table into a variable&lt;BR /&gt;Let vNumMonthsInRange = Peek('NumMonthsInRange', 0, 'TempSum');&lt;BR /&gt;DROP TABLE TempSum;&lt;/P&gt;
&lt;P&gt;// Load the final data, distributing Total_Value across the months&lt;BR /&gt;Split_Data:&lt;BR /&gt;LOAD Key, &lt;BR /&gt;Month_Year,&lt;BR /&gt;If(InRange = 1, Total_Value / $(vNumMonthsInRange), 0) as Div_Value&lt;BR /&gt;RESIDENT Data_Temp; // Generate one record for each month in range&lt;BR /&gt;drop fields Month_Year, MakeDate, InRange from Data_Temp;&lt;/P&gt;
&lt;P&gt;//Now load the distinct row, as ts generated duplicated rows column&lt;BR /&gt;NoConcatenate&lt;BR /&gt;Data:&lt;BR /&gt;Load Distinct *&lt;BR /&gt;Resident Data_Temp;&lt;BR /&gt;drop table Data_Temp;&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;//Prepare the final view table&lt;/P&gt;
&lt;P&gt;&lt;BR /&gt;//Let vFieldName = Peek('Month_Year',0,'Split_Data');&lt;BR /&gt;//Let vFieldValue = Peek('Div_Value',0,'Split_Data');&lt;BR /&gt;//&lt;BR /&gt;//join(Data)&lt;BR /&gt;//Load distinct Key,&lt;BR /&gt;// $(vFieldValue) as "$(vFieldName)"&lt;BR /&gt;//Resident Split_Data;&lt;/P&gt;
&lt;P&gt;for i = 0 to NoOfRows('Split_Data') - 1&lt;/P&gt;
&lt;P&gt;// Get the Month_Year field name and Div_Value for the current row&lt;BR /&gt;Let vFieldName = Peek('Month_Year', i, 'Split_Data');&lt;BR /&gt;Let vFieldValue = Peek('Div_Value', i, 'Split_Data');&lt;BR /&gt;&lt;BR /&gt;// Join to the Data table&lt;BR /&gt;JOIN (Data) // Make sure to join to the Data table&lt;BR /&gt;LOAD DISTINCT &lt;BR /&gt;Key, // Keep the existing Key to join on&lt;BR /&gt;$(vFieldValue) as [$(vFieldName)] // Create a new field with the dynamic name&lt;BR /&gt;RESIDENT Split_Data;&lt;/P&gt;
&lt;P&gt;next;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Drop table Split_Data;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="2485966 - Derive measure for the months that fall in a date Range.PNG" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/172988i85BA7D5BD4257D0A/image-size/large?v=v2&amp;amp;px=999" role="button" title="2485966 - Derive measure for the months that fall in a date Range.PNG" alt="2485966 - Derive measure for the months that fall in a date Range.PNG" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 16 Oct 2024 02:13:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/How-to-derive-measure-only-the-specific-month-that-falls-under/m-p/2487240#M101492</guid>
      <dc:creator>Qrishna</dc:creator>
      <dc:date>2024-10-16T02:13:37Z</dc:date>
    </item>
  </channel>
</rss>

