<?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 Comparing Longitudinal Data with Cyclics in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Comparing-Longitudinal-Data-with-Cyclics/m-p/1646730#M63501</link>
    <description>&lt;P&gt;The goal is to create a straight table which includes a cyclic that displays the total difference across all selected Fiscal Months in units between two the forecasts.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Background:&lt;/P&gt;&lt;P&gt;Many forecasts (planning books) are loaded into the application for comparison.&lt;/P&gt;&lt;P&gt;Intially the user selects two periods to compare (primary and secondary).&lt;/P&gt;&lt;P&gt;The challenge:&amp;nbsp;We had to stitch two values together, actuals + forecast, to get a true comparison between the forecasts (planning books).&lt;/P&gt;&lt;P&gt;The fields:&lt;/P&gt;&lt;P&gt;[APO Final Forecast] -&amp;gt; is the final forecast for a product by month for a given planning book&lt;/P&gt;&lt;P&gt;[APO Order Qty] -&amp;gt; is the actual sales&lt;/P&gt;&lt;P&gt;So the idea to get actuals + forecast is for when, relative to the selected planning book, a month is in the past use the Actuals otherwise use the planning book.&lt;BR /&gt;&lt;BR /&gt;This was helpful but didn't solve.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/t5/QlikView-App-Development/Aggr-Function-using-Cyclic-Groups/m-p/158354#M33464" target="_blank"&gt;https://community.qlik.com/t5/QlikView-App-Development/Aggr-Function-using-Cyclic-Groups/m-p/158354#M33464&lt;/A&gt;&lt;/P&gt;&lt;P&gt;This code works in a straight table without cyclic:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;sum( 
 aggr(
if(SUM({$&amp;lt;PlanPeriod={$(vSecondarySelected)}&amp;gt;}[APO Final Forecast])&amp;gt;0,SUM({$&amp;lt;PlanPeriod={$(vSecondarySelected)}&amp;gt;}[APO Final Forecast]),SUM({$&amp;lt;PlanPeriod={$(vPlanningPeriodCur)}&amp;gt;}([APO Order Qty])))
- if(SUM({$&amp;lt;PlanPeriod={$(vPrimarySelected)}&amp;gt;}[APO Final Forecast])&amp;gt;0,SUM({$&amp;lt;PlanPeriod={$(vPrimarySelected)}&amp;gt;}[APO Final Forecast]),SUM({$&amp;lt;PlanPeriod={$(vPlanningPeriodCur)}&amp;gt;}([APO Order Qty])))
      ,[Fiscal Month]))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I tried with the cyclic and it didn't work&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;sum( 
 aggr(
if(SUM({$&amp;lt;PlanPeriod={$(vSecondarySelected)}&amp;gt;}[APO Final Forecast])&amp;gt;0,SUM({$&amp;lt;PlanPeriod={$(vSecondarySelected)}&amp;gt;}[APO Final Forecast]),SUM({$&amp;lt;PlanPeriod={$(vPlanningPeriodCur)}&amp;gt;}([APO Order Qty])))
- if(SUM({$&amp;lt;PlanPeriod={$(vPrimarySelected)}&amp;gt;}[APO Final Forecast])&amp;gt;0,SUM({$&amp;lt;PlanPeriod={$(vPrimarySelected)}&amp;gt;}[APO Final Forecast]),SUM({$&amp;lt;PlanPeriod={$(vPlanningPeriodCur)}&amp;gt;}([APO Order Qty])))
       ,  $(=GetCurrentField([Summary Cyclic])) ,[Fiscal Month]    ????   
      )
      )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The cyclic has dimensions like Forecast Material, Product Line, and Product Type&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 04:07:34 GMT</pubDate>
    <dc:creator>bobswidarski</dc:creator>
    <dc:date>2024-11-16T04:07:34Z</dc:date>
    <item>
      <title>Comparing Longitudinal Data with Cyclics</title>
      <link>https://community.qlik.com/t5/App-Development/Comparing-Longitudinal-Data-with-Cyclics/m-p/1646730#M63501</link>
      <description>&lt;P&gt;The goal is to create a straight table which includes a cyclic that displays the total difference across all selected Fiscal Months in units between two the forecasts.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Background:&lt;/P&gt;&lt;P&gt;Many forecasts (planning books) are loaded into the application for comparison.&lt;/P&gt;&lt;P&gt;Intially the user selects two periods to compare (primary and secondary).&lt;/P&gt;&lt;P&gt;The challenge:&amp;nbsp;We had to stitch two values together, actuals + forecast, to get a true comparison between the forecasts (planning books).&lt;/P&gt;&lt;P&gt;The fields:&lt;/P&gt;&lt;P&gt;[APO Final Forecast] -&amp;gt; is the final forecast for a product by month for a given planning book&lt;/P&gt;&lt;P&gt;[APO Order Qty] -&amp;gt; is the actual sales&lt;/P&gt;&lt;P&gt;So the idea to get actuals + forecast is for when, relative to the selected planning book, a month is in the past use the Actuals otherwise use the planning book.&lt;BR /&gt;&lt;BR /&gt;This was helpful but didn't solve.&lt;/P&gt;&lt;P&gt;&lt;A href="https://community.qlik.com/t5/QlikView-App-Development/Aggr-Function-using-Cyclic-Groups/m-p/158354#M33464" target="_blank"&gt;https://community.qlik.com/t5/QlikView-App-Development/Aggr-Function-using-Cyclic-Groups/m-p/158354#M33464&lt;/A&gt;&lt;/P&gt;&lt;P&gt;This code works in a straight table without cyclic:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;sum( 
 aggr(
if(SUM({$&amp;lt;PlanPeriod={$(vSecondarySelected)}&amp;gt;}[APO Final Forecast])&amp;gt;0,SUM({$&amp;lt;PlanPeriod={$(vSecondarySelected)}&amp;gt;}[APO Final Forecast]),SUM({$&amp;lt;PlanPeriod={$(vPlanningPeriodCur)}&amp;gt;}([APO Order Qty])))
- if(SUM({$&amp;lt;PlanPeriod={$(vPrimarySelected)}&amp;gt;}[APO Final Forecast])&amp;gt;0,SUM({$&amp;lt;PlanPeriod={$(vPrimarySelected)}&amp;gt;}[APO Final Forecast]),SUM({$&amp;lt;PlanPeriod={$(vPlanningPeriodCur)}&amp;gt;}([APO Order Qty])))
      ,[Fiscal Month]))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This is what I tried with the cyclic and it didn't work&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;sum( 
 aggr(
if(SUM({$&amp;lt;PlanPeriod={$(vSecondarySelected)}&amp;gt;}[APO Final Forecast])&amp;gt;0,SUM({$&amp;lt;PlanPeriod={$(vSecondarySelected)}&amp;gt;}[APO Final Forecast]),SUM({$&amp;lt;PlanPeriod={$(vPlanningPeriodCur)}&amp;gt;}([APO Order Qty])))
- if(SUM({$&amp;lt;PlanPeriod={$(vPrimarySelected)}&amp;gt;}[APO Final Forecast])&amp;gt;0,SUM({$&amp;lt;PlanPeriod={$(vPrimarySelected)}&amp;gt;}[APO Final Forecast]),SUM({$&amp;lt;PlanPeriod={$(vPlanningPeriodCur)}&amp;gt;}([APO Order Qty])))
       ,  $(=GetCurrentField([Summary Cyclic])) ,[Fiscal Month]    ????   
      )
      )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The cyclic has dimensions like Forecast Material, Product Line, and Product Type&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 04:07:34 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Comparing-Longitudinal-Data-with-Cyclics/m-p/1646730#M63501</guid>
      <dc:creator>bobswidarski</dc:creator>
      <dc:date>2024-11-16T04:07:34Z</dc:date>
    </item>
    <item>
      <title>Re: Comparing Longitudinal Data with Cyclics |   Set proper conditions for set analysis</title>
      <link>https://community.qlik.com/t5/App-Development/Comparing-Longitudinal-Data-with-Cyclics/m-p/1647217#M63502</link>
      <description>&lt;P&gt;Internal support got me the answer. The answer was in the code structure and set analysis.&amp;nbsp; This was no t a cyclic issue in the end.&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.youtube.com/watch?v=YMQJnKMkfxg" target="_blank"&gt;https://www.youtube.com/watch?v=YMQJnKMkfxg&lt;/A&gt;&lt;/P&gt;&lt;P&gt;Changes that helped:&lt;/P&gt;&lt;P&gt;1.&amp;nbsp; &amp;nbsp;Changing from SUM(AGGR(SUM())) structure to one sum.&lt;/P&gt;&lt;P&gt;2.&amp;nbsp; Adding a condition for [Fiscal Month]&amp;nbsp; which basically replaced the if(sum()) statement&lt;/P&gt;&lt;P&gt;3.&amp;nbsp; use of *=&amp;nbsp; (star equals) to respect selections&lt;/P&gt;&lt;P&gt;4.&amp;nbsp; a snippet of code the converts Planning Book names to the same format as [Fiscal Month]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Final code that works:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;(
SUM({$&amp;lt;PlanPeriod={$(vSecondarySelected)},[Fiscal Month]*={"&amp;gt;=$(=date(date#(capitalize(vSecondarySelected),'MMMYY'),'YYYYMM'))"}&amp;gt;}[APO Final Forecast])
+
SUM({$&amp;lt;PlanPeriod={$(vPlanningPeriodCur)},[Fiscal Month]*={"&amp;lt;$(=date(date#(capitalize(vSecondarySelected),'MMMYY'),'YYYYMM'))"}&amp;gt;}[APO Order Qty])
)
-
(
SUM({$&amp;lt;PlanPeriod={$(vPrimarySelected)},[Fiscal Month]*={"&amp;gt;=$(=date(date#(capitalize(vPrimarySelected),'MMMYY'),'YYYYMM'))"}&amp;gt;}[APO Final Forecast])
+
SUM({$&amp;lt;PlanPeriod={$(vPlanningPeriodCur)},[Fiscal Month]*={"&amp;lt;$(=date(date#(capitalize(vPrimarySelected),'MMMYY'),'YYYYMM'))"}&amp;gt;}[APO Order Qty])
)
&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 14 Nov 2019 21:40:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Comparing-Longitudinal-Data-with-Cyclics/m-p/1647217#M63502</guid>
      <dc:creator>bobswidarski</dc:creator>
      <dc:date>2019-11-14T21:40:14Z</dc:date>
    </item>
  </channel>
</rss>

