<?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: Can these if expressions be replace by set analysis? in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Can-these-if-expressions-be-replace-by-set-analysis/m-p/1526005#M747167</link>
    <description>&lt;P&gt;Hi Susan,&lt;/P&gt;&lt;P&gt;It looks like that performance problem is caused by big number of expressions in your IF statements. Qlick is calculating all of them, only then it fulfills IF condition. So, instead of 20+ Sum statements, try approach below with passing parameter.&lt;/P&gt;&lt;P&gt;1. Set a parameter variable based on your logic&lt;/P&gt;&lt;P&gt;&amp;nbsp; exp_YTDValueParameter : '=&lt;BR /&gt;&lt;BR /&gt;pick( match( right( %FCOMonthlyReportingTime, 3 ),&lt;BR /&gt;// Month columns&lt;BR /&gt;'/01', '/02', '/03', '/04', '/05', '/06', '/07', '/08', '/09', '/10', '/11', '/12',&lt;BR /&gt;'YTD',&lt;BR /&gt;// Year columns&lt;BR /&gt;'014', '015', '016', '017', '018', '019', '020', '021', '022' ),&lt;BR /&gt;// Jan - Nov&lt;BR /&gt;$(=FCOMonthlyDashboardYear * 1000 + 20),&lt;BR /&gt;$(=FCOMonthlyDashboardYear * 1000 + 30),&lt;BR /&gt;$(=FCOMonthlyDashboardYear * 1000 + 40),&lt;BR /&gt;$(=FCOMonthlyDashboardYear * 1000 + 50),&lt;BR /&gt;$(=FCOMonthlyDashboardYear * 1000 + 60),&lt;BR /&gt;$(=FCOMonthlyDashboardYear * 1000 + 70),&lt;BR /&gt;$(=FCOMonthlyDashboardYear * 1000 + 80),&lt;BR /&gt;$(=FCOMonthlyDashboardYear * 1000 + 90),&lt;BR /&gt;$(=FCOMonthlyDashboardYear * 1000 + 100),&lt;BR /&gt;$(=FCOMonthlyDashboardYear * 1000 + 110),&lt;BR /&gt;$(=FCOMonthlyDashboardYear * 1000 + 120),&lt;BR /&gt;// December is next year's January&lt;BR /&gt;$(=FCOMonthlyDashboardYear * 1000 + 1010),&lt;BR /&gt;// YTD is the minimum of latest snapshot or january of next year&lt;BR /&gt;$(=RangeMin( Max( TimeIdForSnapshot_Realized ), FCOMonthlyDashboardYear * 1000 + 1010 ) ) ,&lt;BR /&gt;// Year columns show next year's January.&lt;BR /&gt;'2015010',&lt;BR /&gt;'2016010',&lt;BR /&gt;'2017010',&lt;BR /&gt;'2018010',&lt;BR /&gt;'2019010',&lt;BR /&gt;'2010010',&lt;BR /&gt;'2021010',&lt;BR /&gt;'2022010',&lt;BR /&gt;'2023010'&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Use this variable in the following way:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;= If( %FCOMonthlyReportingTimeId = 'P',&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;If( GetSelectedCount( Plant_0_Desc ) = 0 AND GetSelectedCount( Plant_4_Desc ) = 0 AND GetSelectedCount( Product_3_Desc ) = 0,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;sum( { &amp;lt; %TimeSelection =, TargetGroupDesc = {'FCOVerifiedSavingsTotal'} &amp;gt; } TargetAmount * CurrencyRate ) / 1000,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;If( wildmatch( getFieldSelections( Plant_4_Desc ), '*India*' ) &amp;gt; 0,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;0,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;sum( { &amp;lt; %TimeSelection =, TargetGroupDesc = {'FCOVerifiedSavingsCatOrPlant'} &amp;gt; } TargetAmount * CurrencyRate ) / 1000&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; )&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; ),&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;sum( { &amp;lt; TimeIdForSnapshot_Realized = { '$(=exp_YTDValueParameter)'}, %TimeSelection = &amp;gt; } TOTAL &amp;lt;MonthId&amp;gt; NetVerifiedSavings_SNAP_Realized * CurrencyRate ) / 1000&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;As you can see, Qlik will execute your statement only once. Try to use this approach on other columns.&lt;/P&gt;&lt;P&gt;Note, I didn't test the syntax.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Good luck!&lt;/P&gt;</description>
    <pubDate>Thu, 03 Jan 2019 21:06:06 GMT</pubDate>
    <dc:creator>bgerchikov</dc:creator>
    <dc:date>2019-01-03T21:06:06Z</dc:date>
    <item>
      <title>Can these if expressions be replace by set analysis?</title>
      <link>https://community.qlik.com/t5/QlikView/Can-these-if-expressions-be-replace-by-set-analysis/m-p/1525812#M747166</link>
      <description>&lt;P&gt;My mission is to improve performance of old dashboards.&amp;nbsp;Currently I have replaced simple if statements by&amp;nbsp;pick(match()). But below if statements are too complicated to me.&amp;nbsp;The ones with range condition, I have no idea how to do. The other ones I have tried to use nested pick(match(), but got different result. Can you please help?&lt;/P&gt;&lt;P&gt;Thank you a million times for your time!&lt;/P&gt;&lt;P&gt;Best regards,&lt;/P&gt;&lt;P&gt;Susan&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1)&lt;BR /&gt;= Column(5) / Column(2) -- I thought to use sum(&lt;SPAN&gt;Column(5) / Column(2)) to improve performance. But it doesn't work with sum.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;2)&lt;BR /&gt;= If( %FCOMonthlyReportingTimeId = 'P',&lt;BR /&gt;If( GetSelectedCount( Plant_0_Desc ) = 0 AND GetSelectedCount( Plant_4_Desc ) = 0 AND GetSelectedCount( Product_3_Desc ) = 0,&lt;BR /&gt;sum( { &amp;lt; %TimeSelection =, TargetGroupDesc = {'FCOVerifiedSavingsTotal'} &amp;gt; } TargetAmount * CurrencyRate ) / 1000,&lt;BR /&gt;If( wildmatch( getFieldSelections( Plant_4_Desc ), '*India*' ) &amp;gt; 0,&lt;BR /&gt;// All category values are under India\Valves, because they have to be shown when Valves is selected&lt;BR /&gt;// If India is selected, 0 is shown&lt;BR /&gt;0,&lt;BR /&gt;sum( { &amp;lt; %TimeSelection =, TargetGroupDesc = {'FCOVerifiedSavingsCatOrPlant'} &amp;gt; } TargetAmount * CurrencyRate ) / 1000&lt;BR /&gt;)&lt;BR /&gt;),&lt;BR /&gt;pick( match( right( %FCOMonthlyReportingTime, 3 ),&lt;BR /&gt;// Month columns&lt;BR /&gt;'/01', '/02', '/03', '/04', '/05', '/06', '/07', '/08', '/09', '/10', '/11', '/12',&lt;BR /&gt;'YTD',&lt;BR /&gt;// Year columns&lt;BR /&gt;'014', '015', '016', '017', '018', '019', '020', '021', '022' ),&lt;BR /&gt;// Jan - Nov&lt;BR /&gt;sum( { &amp;lt; TimeIdForSnapshot_Realized = {$(=FCOMonthlyDashboardYear * 1000 + 20)}, %TimeSelection = &amp;gt; } TOTAL &amp;lt;MonthId&amp;gt; NetVerifiedSavings_SNAP_Realized * CurrencyRate ) / 1000,&lt;BR /&gt;sum( { &amp;lt; TimeIdForSnapshot_Realized = {$(=FCOMonthlyDashboardYear * 1000 + 30)}, %TimeSelection = &amp;gt; } TOTAL &amp;lt;MonthId&amp;gt; NetVerifiedSavings_SNAP_Realized * CurrencyRate ) / 1000,&lt;BR /&gt;sum( { &amp;lt; TimeIdForSnapshot_Realized = {$(=FCOMonthlyDashboardYear * 1000 + 40)}, %TimeSelection = &amp;gt; } TOTAL &amp;lt;MonthId&amp;gt; NetVerifiedSavings_SNAP_Realized * CurrencyRate ) / 1000,&lt;BR /&gt;sum( { &amp;lt; TimeIdForSnapshot_Realized = {$(=FCOMonthlyDashboardYear * 1000 + 50)}, %TimeSelection = &amp;gt; } TOTAL &amp;lt;MonthId&amp;gt; NetVerifiedSavings_SNAP_Realized * CurrencyRate ) / 1000,&lt;BR /&gt;sum( { &amp;lt; TimeIdForSnapshot_Realized = {$(=FCOMonthlyDashboardYear * 1000 + 60)}, %TimeSelection = &amp;gt; } TOTAL &amp;lt;MonthId&amp;gt; NetVerifiedSavings_SNAP_Realized * CurrencyRate ) / 1000,&lt;BR /&gt;sum( { &amp;lt; TimeIdForSnapshot_Realized = {$(=FCOMonthlyDashboardYear * 1000 + 70)}, %TimeSelection = &amp;gt; } TOTAL &amp;lt;MonthId&amp;gt; NetVerifiedSavings_SNAP_Realized * CurrencyRate ) / 1000,&lt;BR /&gt;sum( { &amp;lt; TimeIdForSnapshot_Realized = {$(=FCOMonthlyDashboardYear * 1000 + 80)}, %TimeSelection = &amp;gt; } TOTAL &amp;lt;MonthId&amp;gt; NetVerifiedSavings_SNAP_Realized * CurrencyRate ) / 1000,&lt;BR /&gt;sum( { &amp;lt; TimeIdForSnapshot_Realized = {$(=FCOMonthlyDashboardYear * 1000 + 90)}, %TimeSelection = &amp;gt; } TOTAL &amp;lt;MonthId&amp;gt; NetVerifiedSavings_SNAP_Realized * CurrencyRate ) / 1000,&lt;BR /&gt;sum( { &amp;lt; TimeIdForSnapshot_Realized = {$(=FCOMonthlyDashboardYear * 1000 + 100)}, %TimeSelection = &amp;gt; } TOTAL &amp;lt;MonthId&amp;gt; NetVerifiedSavings_SNAP_Realized * CurrencyRate ) / 1000,&lt;BR /&gt;sum( { &amp;lt; TimeIdForSnapshot_Realized = {$(=FCOMonthlyDashboardYear * 1000 + 110)}, %TimeSelection = &amp;gt; } TOTAL &amp;lt;MonthId&amp;gt; NetVerifiedSavings_SNAP_Realized * CurrencyRate ) / 1000,&lt;BR /&gt;sum( { &amp;lt; TimeIdForSnapshot_Realized = {$(=FCOMonthlyDashboardYear * 1000 + 120)}, %TimeSelection = &amp;gt; } TOTAL &amp;lt;MonthId&amp;gt; NetVerifiedSavings_SNAP_Realized * CurrencyRate ) / 1000,&lt;BR /&gt;// December is next year's January&lt;BR /&gt;sum( { &amp;lt; TimeIdForSnapshot_Realized = {$(=FCOMonthlyDashboardYear * 1000 + 1010)}, %TimeSelection = &amp;gt; } TOTAL &amp;lt;MonthId&amp;gt; NetVerifiedSavings_SNAP_Realized * CurrencyRate ) / 1000,&lt;BR /&gt;// YTD is the minimum of latest snapshot or january of next year&lt;BR /&gt;sum( { &amp;lt; TimeIdForSnapshot_Realized = {$(=RangeMin( Max( TimeIdForSnapshot_Realized ), FCOMonthlyDashboardYear * 1000 + 1010 ) ) }, %TimeSelection = &amp;gt; } TOTAL &amp;lt;MonthId&amp;gt; NetVerifiedSavings_SNAP_Realized * CurrencyRate ) / 1000,&lt;BR /&gt;// Year columns show next year's January.&lt;BR /&gt;sum( { &amp;lt; TimeIdForSnapshot_Realized = {'2015010'}, %TimeSelection = &amp;gt; } TOTAL &amp;lt;MonthId&amp;gt; NetVerifiedSavings_SNAP_Realized * CurrencyRate ) / 1000,&lt;BR /&gt;sum( { &amp;lt; TimeIdForSnapshot_Realized = {'2016010'}, %TimeSelection = &amp;gt; } TOTAL &amp;lt;MonthId&amp;gt; NetVerifiedSavings_SNAP_Realized * CurrencyRate ) / 1000,&lt;BR /&gt;sum( { &amp;lt; TimeIdForSnapshot_Realized = {'2017010'}, %TimeSelection = &amp;gt; } TOTAL &amp;lt;MonthId&amp;gt; NetVerifiedSavings_SNAP_Realized * CurrencyRate ) / 1000,&lt;BR /&gt;sum( { &amp;lt; TimeIdForSnapshot_Realized = {'2018010'}, %TimeSelection = &amp;gt; } TOTAL &amp;lt;MonthId&amp;gt; NetVerifiedSavings_SNAP_Realized * CurrencyRate ) / 1000,&lt;BR /&gt;sum( { &amp;lt; TimeIdForSnapshot_Realized = {'2019010'}, %TimeSelection = &amp;gt; } TOTAL &amp;lt;MonthId&amp;gt; NetVerifiedSavings_SNAP_Realized * CurrencyRate ) / 1000,&lt;BR /&gt;sum( { &amp;lt; TimeIdForSnapshot_Realized = {'2010010'}, %TimeSelection = &amp;gt; } TOTAL &amp;lt;MonthId&amp;gt; NetVerifiedSavings_SNAP_Realized * CurrencyRate ) / 1000,&lt;BR /&gt;sum( { &amp;lt; TimeIdForSnapshot_Realized = {'2021010'}, %TimeSelection = &amp;gt; } TOTAL &amp;lt;MonthId&amp;gt; NetVerifiedSavings_SNAP_Realized * CurrencyRate ) / 1000,&lt;BR /&gt;sum( { &amp;lt; TimeIdForSnapshot_Realized = {'2022010'}, %TimeSelection = &amp;gt; } TOTAL &amp;lt;MonthId&amp;gt; NetVerifiedSavings_SNAP_Realized * CurrencyRate ) / 1000,&lt;BR /&gt;sum( { &amp;lt; TimeIdForSnapshot_Realized = {'2023010'}, %TimeSelection = &amp;gt; } TOTAL &amp;lt;MonthId&amp;gt; NetVerifiedSavings_SNAP_Realized * CurrencyRate ) / 1000&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;3)&lt;BR /&gt;= If( %FCOMonthlyReportingTimeId = 'P',&lt;BR /&gt;If( GetPossibleCount( Plant_0_Desc ) &amp;lt;= 1 OR GetPossibleCount( Product_3_Desc ) &amp;lt;= 1,&lt;BR /&gt;sum( { &amp;lt; %TimeSelection =, TargetGroupDesc = {'FCOOTDCatOrPlantPercent'} &amp;gt; } TargetAmount ),&lt;BR /&gt;sum( { &amp;lt; %TimeSelection =, TargetGroupDesc = {'FCOOTDTotalPercent'} &amp;gt; } TargetAmount )&lt;BR /&gt;),&lt;BR /&gt;count( { &amp;lt; %TimeSelection = , StepId = {1001}, OTDIncluded_0_Desc = {"Incl"}, SourceTableName = {"S_PurchaseOrders"}, OTDToConfirmed_Receiving = {"1"} &amp;gt; } OTDToConfirmed_Receiving)&lt;BR /&gt;/&lt;BR /&gt;count( { &amp;lt; %TimeSelection = , StepId = {1001}, OTDIncluded_0_Desc = {"Incl"}, SourceTableName = {"S_PurchaseOrders"}, OTDToConfirmed_Receiving = {"*"} &amp;gt; } OTDToConfirmed_Receiving)&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;4)&lt;BR /&gt;= If( %FCOMonthlyReportingTimeId = 'P',&lt;BR /&gt;If( GetPossibleCount( Plant_0_Desc ) &amp;lt;= 1 AND GetPossibleCount( Product_3_Desc ) &amp;lt;= 1,&lt;BR /&gt;/* If one plant and one product category is selected */&lt;BR /&gt;sum( { &amp;lt; %TimeSelection =, TargetGroupDesc = {'FCOOver14DaysCatAndPlantPercent'} &amp;gt; } TargetAmount ),&lt;BR /&gt;If( GetPossibleCount( Plant_0_Desc ) &amp;lt;= 1 OR GetPossibleCount( Product_3_Desc ) &amp;lt;= 1,&lt;BR /&gt;/* If one plant or product category is selected */&lt;BR /&gt;sum( { &amp;lt; %TimeSelection =, TargetGroupDesc = {'FCOOver14DaysCatOrPlantPercent'} &amp;gt; } TargetAmount ),&lt;BR /&gt;sum( { &amp;lt; %TimeSelection =, TargetGroupDesc = {'FCOOver14DaysTotalPercent'} &amp;gt; } TargetAmount )&lt;BR /&gt;)&lt;BR /&gt;),&lt;BR /&gt;If ( Count( { &amp;lt; %TimeSelection = , StepId = {1001}, OTDIncluded_0_Desc = {"Incl"}, SourceTableName = {"S_PurchaseOrders"}, Over14DaysLateToConfirmed_Receiving={"*"} &amp;gt; } Over14DaysLateToConfirmed_Receiving ) &amp;gt; 0,&lt;BR /&gt;count( { &amp;lt; %TimeSelection = , StepId = {1001}, OTDIncluded_0_Desc = {"Incl"}, SourceTableName = {"S_PurchaseOrders"}, Over14DaysLateToConfirmed_Receiving={"1"} &amp;gt; } Over14DaysLateToConfirmed_Receiving )&lt;BR /&gt;/&lt;BR /&gt;count( { &amp;lt; %TimeSelection = , StepId = {1001}, OTDIncluded_0_Desc = {"Incl"}, SourceTableName = {"S_PurchaseOrders"}, Over14DaysLateToConfirmed_Receiving={"*"} &amp;gt; } Over14DaysLateToConfirmed_Receiving )&lt;BR /&gt;&lt;BR /&gt;, 0)&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;5)&lt;BR /&gt;= If( %FCOMonthlyReportingTimeId = 'P',&lt;BR /&gt;'',&lt;BR /&gt;If( Len( %FCOMonthlyReportingTime ) = 7,&lt;BR /&gt;// Monthly columns&lt;BR /&gt;pick( match( %FCOMonthlyReportingTimeId,&lt;BR /&gt;FCOMonthlyDashboardYear * 1000 + 10, FCOMonthlyDashboardYear * 1000 + 20, FCOMonthlyDashboardYear * 1000 + 30, FCOMonthlyDashboardYear * 1000 + 40,&lt;BR /&gt;FCOMonthlyDashboardYear * 1000 + 50, FCOMonthlyDashboardYear * 1000 + 60, FCOMonthlyDashboardYear * 1000 + 70, FCOMonthlyDashboardYear * 1000 + 80,&lt;BR /&gt;FCOMonthlyDashboardYear * 1000 + 90, FCOMonthlyDashboardYear * 1000 + 100, FCOMonthlyDashboardYear * 1000 + 110, FCOMonthlyDashboardYear * 1000 + 120 ),&lt;BR /&gt;count( { &amp;lt; MonthId = {$(=FCOMonthlyDashboardYear * 1000 + 10)}, %TimeSelection = , StepId = {29}, SourceTableName = {"S_Purchasing"} &amp;gt; } total &amp;lt;MonthId&amp;gt; distinct Supplier_0_Desc ),&lt;BR /&gt;count( { &amp;lt; MonthId = {"&amp;gt;=$(=FCOMonthlyDashboardYear * 1000 + 10)&amp;lt;=$(=FCOMonthlyDashboardYear * 1000 + 20)"}, %TimeSelection = , StepId = {29}, SourceTableName = {"S_Purchasing"} &amp;gt; } total &amp;lt;MonthId&amp;gt; distinct Supplier_0_Desc ),&lt;BR /&gt;count( { &amp;lt; MonthId = {"&amp;gt;=$(=FCOMonthlyDashboardYear * 1000 + 10)&amp;lt;=$(=FCOMonthlyDashboardYear * 1000 + 30)"}, %TimeSelection = , StepId = {29}, SourceTableName = {"S_Purchasing"} &amp;gt; } total &amp;lt;MonthId&amp;gt; distinct Supplier_0_Desc ),&lt;BR /&gt;count( { &amp;lt; MonthId = {"&amp;gt;=$(=FCOMonthlyDashboardYear * 1000 + 10)&amp;lt;=$(=FCOMonthlyDashboardYear * 1000 + 40)"}, %TimeSelection = , StepId = {29}, SourceTableName = {"S_Purchasing"} &amp;gt; } total &amp;lt;MonthId&amp;gt; distinct Supplier_0_Desc ),&lt;BR /&gt;count( { &amp;lt; MonthId = {"&amp;gt;=$(=FCOMonthlyDashboardYear * 1000 + 10)&amp;lt;=$(=FCOMonthlyDashboardYear * 1000 + 50)"}, %TimeSelection = , StepId = {29}, SourceTableName = {"S_Purchasing"} &amp;gt; } total &amp;lt;MonthId&amp;gt; distinct Supplier_0_Desc ),&lt;BR /&gt;count( { &amp;lt; MonthId = {"&amp;gt;=$(=FCOMonthlyDashboardYear * 1000 + 10)&amp;lt;=$(=FCOMonthlyDashboardYear * 1000 + 60)"}, %TimeSelection = , StepId = {29}, SourceTableName = {"S_Purchasing"} &amp;gt; } total &amp;lt;MonthId&amp;gt; distinct Supplier_0_Desc ),&lt;BR /&gt;count( { &amp;lt; MonthId = {"&amp;gt;=$(=FCOMonthlyDashboardYear * 1000 + 10)&amp;lt;=$(=FCOMonthlyDashboardYear * 1000 + 70)"}, %TimeSelection = , StepId = {29}, SourceTableName = {"S_Purchasing"} &amp;gt; } total &amp;lt;MonthId&amp;gt; distinct Supplier_0_Desc ),&lt;BR /&gt;count( { &amp;lt; MonthId = {"&amp;gt;=$(=FCOMonthlyDashboardYear * 1000 + 10)&amp;lt;=$(=FCOMonthlyDashboardYear * 1000 + 80)"}, %TimeSelection = , StepId = {29}, SourceTableName = {"S_Purchasing"} &amp;gt; } total &amp;lt;MonthId&amp;gt; distinct Supplier_0_Desc ),&lt;BR /&gt;count( { &amp;lt; MonthId = {"&amp;gt;=$(=FCOMonthlyDashboardYear * 1000 + 10)&amp;lt;=$(=FCOMonthlyDashboardYear * 1000 + 90)"}, %TimeSelection = , StepId = {29}, SourceTableName = {"S_Purchasing"} &amp;gt; } total &amp;lt;MonthId&amp;gt; distinct Supplier_0_Desc ),&lt;BR /&gt;count( { &amp;lt; MonthId = {"&amp;gt;=$(=FCOMonthlyDashboardYear * 1000 + 10)&amp;lt;=$(=FCOMonthlyDashboardYear * 1000 + 100)"}, %TimeSelection = , StepId = {29}, SourceTableName = {"S_Purchasing"} &amp;gt; } total &amp;lt;MonthId&amp;gt; distinct Supplier_0_Desc ),&lt;BR /&gt;count( { &amp;lt; MonthId = {"&amp;gt;=$(=FCOMonthlyDashboardYear * 1000 + 10)&amp;lt;=$(=FCOMonthlyDashboardYear * 1000 + 110)"}, %TimeSelection = , StepId = {29}, SourceTableName = {"S_Purchasing"} &amp;gt; } total &amp;lt;MonthId&amp;gt; distinct Supplier_0_Desc ),&lt;BR /&gt;count( { &amp;lt; YearId = { $(=FCOMonthlyDashboardYear) }, %TimeSelection = , StepId = {29}, SourceTableName = {"S_Purchasing"} &amp;gt; } total &amp;lt;MonthId&amp;gt; distinct Supplier_0_Desc )&lt;BR /&gt;),&lt;BR /&gt;// Other columns&lt;BR /&gt;count( { &amp;lt; %TimeSelection = , StepId = {29}, SourceTableName = {"S_Purchasing"} &amp;gt; } distinct Supplier_0_Desc )&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 04:51:31 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Can-these-if-expressions-be-replace-by-set-analysis/m-p/1525812#M747166</guid>
      <dc:creator>Huiying</dc:creator>
      <dc:date>2024-11-16T04:51:31Z</dc:date>
    </item>
    <item>
      <title>Re: Can these if expressions be replace by set analysis?</title>
      <link>https://community.qlik.com/t5/QlikView/Can-these-if-expressions-be-replace-by-set-analysis/m-p/1526005#M747167</link>
      <description>&lt;P&gt;Hi Susan,&lt;/P&gt;&lt;P&gt;It looks like that performance problem is caused by big number of expressions in your IF statements. Qlick is calculating all of them, only then it fulfills IF condition. So, instead of 20+ Sum statements, try approach below with passing parameter.&lt;/P&gt;&lt;P&gt;1. Set a parameter variable based on your logic&lt;/P&gt;&lt;P&gt;&amp;nbsp; exp_YTDValueParameter : '=&lt;BR /&gt;&lt;BR /&gt;pick( match( right( %FCOMonthlyReportingTime, 3 ),&lt;BR /&gt;// Month columns&lt;BR /&gt;'/01', '/02', '/03', '/04', '/05', '/06', '/07', '/08', '/09', '/10', '/11', '/12',&lt;BR /&gt;'YTD',&lt;BR /&gt;// Year columns&lt;BR /&gt;'014', '015', '016', '017', '018', '019', '020', '021', '022' ),&lt;BR /&gt;// Jan - Nov&lt;BR /&gt;$(=FCOMonthlyDashboardYear * 1000 + 20),&lt;BR /&gt;$(=FCOMonthlyDashboardYear * 1000 + 30),&lt;BR /&gt;$(=FCOMonthlyDashboardYear * 1000 + 40),&lt;BR /&gt;$(=FCOMonthlyDashboardYear * 1000 + 50),&lt;BR /&gt;$(=FCOMonthlyDashboardYear * 1000 + 60),&lt;BR /&gt;$(=FCOMonthlyDashboardYear * 1000 + 70),&lt;BR /&gt;$(=FCOMonthlyDashboardYear * 1000 + 80),&lt;BR /&gt;$(=FCOMonthlyDashboardYear * 1000 + 90),&lt;BR /&gt;$(=FCOMonthlyDashboardYear * 1000 + 100),&lt;BR /&gt;$(=FCOMonthlyDashboardYear * 1000 + 110),&lt;BR /&gt;$(=FCOMonthlyDashboardYear * 1000 + 120),&lt;BR /&gt;// December is next year's January&lt;BR /&gt;$(=FCOMonthlyDashboardYear * 1000 + 1010),&lt;BR /&gt;// YTD is the minimum of latest snapshot or january of next year&lt;BR /&gt;$(=RangeMin( Max( TimeIdForSnapshot_Realized ), FCOMonthlyDashboardYear * 1000 + 1010 ) ) ,&lt;BR /&gt;// Year columns show next year's January.&lt;BR /&gt;'2015010',&lt;BR /&gt;'2016010',&lt;BR /&gt;'2017010',&lt;BR /&gt;'2018010',&lt;BR /&gt;'2019010',&lt;BR /&gt;'2010010',&lt;BR /&gt;'2021010',&lt;BR /&gt;'2022010',&lt;BR /&gt;'2023010'&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. Use this variable in the following way:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;= If( %FCOMonthlyReportingTimeId = 'P',&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;If( GetSelectedCount( Plant_0_Desc ) = 0 AND GetSelectedCount( Plant_4_Desc ) = 0 AND GetSelectedCount( Product_3_Desc ) = 0,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;sum( { &amp;lt; %TimeSelection =, TargetGroupDesc = {'FCOVerifiedSavingsTotal'} &amp;gt; } TargetAmount * CurrencyRate ) / 1000,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;If( wildmatch( getFieldSelections( Plant_4_Desc ), '*India*' ) &amp;gt; 0,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;0,&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;sum( { &amp;lt; %TimeSelection =, TargetGroupDesc = {'FCOVerifiedSavingsCatOrPlant'} &amp;gt; } TargetAmount * CurrencyRate ) / 1000&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; )&lt;BR /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp; ),&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;sum( { &amp;lt; TimeIdForSnapshot_Realized = { '$(=exp_YTDValueParameter)'}, %TimeSelection = &amp;gt; } TOTAL &amp;lt;MonthId&amp;gt; NetVerifiedSavings_SNAP_Realized * CurrencyRate ) / 1000&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;)&lt;/P&gt;&lt;P&gt;As you can see, Qlik will execute your statement only once. Try to use this approach on other columns.&lt;/P&gt;&lt;P&gt;Note, I didn't test the syntax.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Good luck!&lt;/P&gt;</description>
      <pubDate>Thu, 03 Jan 2019 21:06:06 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Can-these-if-expressions-be-replace-by-set-analysis/m-p/1526005#M747167</guid>
      <dc:creator>bgerchikov</dc:creator>
      <dc:date>2019-01-03T21:06:06Z</dc:date>
    </item>
  </channel>
</rss>

