<?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 Multiple Supplier Rebate Thresholds in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Multiple-Supplier-Rebate-Thresholds/m-p/2000241#M82840</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;New job and new to qlik sense! I was given a project to become familiar with qlik, and have run into some knowledge/experience roadblocks. I would really appreciate any help that can be provided.&lt;/P&gt;
&lt;P&gt;I am trying to create an app that will provide information related to supplier spend, and the rebate we expect to receive based on thresholds.&lt;/P&gt;
&lt;P&gt;Similar to&amp;nbsp;&lt;A href="https://community.qlik.com/t5/QlikView-App-Dev/Help-With-Complex-quot-If-ElseIF-ElseIF-quot-Statement/td-p/1320032" target="_blank" rel="noopener"&gt;https://community.qlik.com/t5/QlikView-App-Dev/Help-With-Complex-quot-If-ElseIF-ElseIF-quot-Statement/td-p/1320032&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I believe there are more complexities required for my app. I will try to give as much context as possible.&lt;/P&gt;
&lt;P&gt;In order to accommodate changing agreements with suppliers, the thresholds and rebate % will be maintained in an excel document that will be loaded as needed.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2022-11-03 101542.png" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/92821iC5FDC3984D0C2036/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2022-11-03 101542.png" alt="Screenshot 2022-11-03 101542.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;As you can see from the sample screenshot, there are different rebate collection periods, and rebate types.&lt;/P&gt;
&lt;P&gt;For the time being I am most concerned with 'Quarterly' and 'Yearly' Rebate Collection Period, and the 'Threshold' Rebate Type.&lt;/P&gt;
&lt;P&gt;Quarterly = The threshold is calculated based on the total amount of PREVIOUS YEAR SPEND. (Rebate paid quarterly)&lt;/P&gt;
&lt;P&gt;Example: Supplier 4 spent $12,000,000 in 2021, effective rebate for any 2022 spend should be 5%&lt;/P&gt;
&lt;P&gt;If ([Rebate Collection Period] = 'Quarterly', Sum({&amp;lt;Year= {'$(=Max(Year)-1)'}&amp;gt;} [Total PO Spend (USD)])) -- Used this to check PY&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yearly = The threshold is calculated based on the total amount YEAR TO DATE (Rebate paid at end of year)&lt;/P&gt;
&lt;P&gt;Example: As spend increases throughout the year, the rebate should reflect this.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If ([Rebate Collection Period] = 'Yearly', Sum({&amp;lt;Year= {'$(=Max(Year))'}&amp;gt;} [Total PO Spend (USD)])) -- Used this to check YTD&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yearly (Mar - Feb) etc... will be for suppliers that use a different fiscal year. I will tackle that after this portion works...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A user will select the 'reporting year' (e.g. 2022), and the output should display rebate values for monthly, quarterly, total. Image below.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2022-11-03 111345.png" style="width: 459px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/92832i47A024D7206A72C3/image-dimensions/459x278?v=v2" width="459" height="278" role="button" title="Screenshot 2022-11-03 111345.png" alt="Screenshot 2022-11-03 111345.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used the following expression to try and find the correct rebate. I believe that it is only choosing the lowest rebate threshold, and not going through the entire statement, as Supplier 4 in above image should be a higher tier.&lt;/P&gt;
&lt;P&gt;IF ([Rebate Collection Period] = 'Yearly',&lt;/P&gt;
&lt;P&gt;If(Sum({&amp;lt;Year = {'$(=Max(Year))'}&amp;gt;} [Total PO Spend (USD)] &amp;gt;= 1 and [Total PO Spend (USD)] &amp;lt;= [Spend Threshold]), Sum({&amp;lt;Month={'Jan'}&amp;gt;}[Total PO Spend (USD)] * Rebate),&lt;BR /&gt;&lt;BR /&gt;If(Sum({&amp;lt;Year = {'$(=Max(Year))'}&amp;gt;} [Total PO Spend (USD)] &amp;gt; [Spend Threshold] and [Total PO Spend (USD)] &amp;lt;= [Spend Threshold2]), Sum({&amp;lt;Month={'Jan'}&amp;gt;}[Total PO Spend (USD)] * Rebate2),&lt;BR /&gt;&lt;BR /&gt;If(Sum({&amp;lt;Year = {'$(=Max(Year))'}&amp;gt;} [Total PO Spend (USD)] &amp;gt; [Spend Threshold2] and [Total PO Spend (USD)] &amp;lt;= [Spend Threshold3]), Sum({&amp;lt;Month={'Jan'}&amp;gt;}[Total PO Spend (USD)] * Rebate3),&lt;BR /&gt;&lt;BR /&gt;If(Sum({&amp;lt;Year = {'$(=Max(Year))'}&amp;gt;} [Total PO Spend (USD)] &amp;gt; [Spend Threshold3] and [Total PO Spend (USD)] &amp;lt;= [Spend Threshold4]), Sum({&amp;lt;Month={'Jan'}&amp;gt;}[Total PO Spend (USD)] * Rebate4),&lt;BR /&gt;&lt;BR /&gt;If(Sum({&amp;lt;Year = {'$(=Max(Year))'}&amp;gt;} [Total PO Spend (USD)] &amp;gt; [Spend Threshold4] and [Total PO Spend (USD)] &amp;lt;= [Spend Threshold5]), Sum({&amp;lt;Month={'Jan'}&amp;gt;}[Total PO Spend (USD)] * Rebate5),&lt;BR /&gt;&lt;BR /&gt;If(Sum({&amp;lt;Year = {'$(=Max(Year))'}&amp;gt;} [Total PO Spend (USD)] &amp;gt; [Spend Threshold5] and [Total PO Spend (USD)] &amp;lt;= [Spend Threshold6]), Sum({&amp;lt;Month={'Jan'}&amp;gt;}[Total PO Spend (USD)] * Rebate6),&lt;/P&gt;
&lt;P&gt;)))))),&lt;/P&gt;
&lt;P&gt;If ([Rebate Collection Period] = 'Quarterly',&lt;/P&gt;
&lt;P&gt;If (Sum({&amp;lt;Year = {'$(=Max(Year)-1)'}&amp;gt;} [Total PO Spend (USD)] &amp;gt;= 1 and [Total PO Spend (USD)] &amp;lt;= [Spend Threshold]), Sum({&amp;lt;Month={'Jan'}&amp;gt;}[Total PO Spend (USD)] * Rebate),&lt;BR /&gt;&lt;BR /&gt;If (Sum({&amp;lt;Year = {'$(=Max(Year)-1)'}&amp;gt;} [Total PO Spend (USD)] &amp;gt; [Spend Threshold] and [Total PO Spend (USD)] &amp;lt;= [Spend Threshold2]), Sum({&amp;lt;Month={'Jan'}&amp;gt;}[Total PO Spend (USD)] * Rebate2),&lt;BR /&gt;&lt;BR /&gt;If (Sum({&amp;lt;Year = {'$(=Max(Year)-1)'}&amp;gt;} [Total PO Spend (USD)] &amp;gt; [Spend Threshold2] and [Total PO Spend (USD)] &amp;lt;= [Spend Threshold3]), Sum({&amp;lt;Month={'Jan'}&amp;gt;}[Total PO Spend (USD)] * Rebate3),&lt;BR /&gt;&lt;BR /&gt;If (Sum({&amp;lt;Year = {'$(=Max(Year)-1)'}&amp;gt;} [Total PO Spend (USD)] &amp;gt; [Spend Threshold3] and [Total PO Spend (USD)] &amp;lt;= [Spend Threshold4]), Sum({&amp;lt;Month={'Jan'}&amp;gt;}[Total PO Spend (USD)] * Rebate4),&lt;BR /&gt;&lt;BR /&gt;If (Sum({&amp;lt;Year = {'$(=Max(Year)-1)'}&amp;gt;} [Total PO Spend (USD)] &amp;gt; [Spend Threshold4] and [Total PO Spend (USD)] &amp;lt;= [Spend Threshold5]), Sum({&amp;lt;Month={'Jan'}&amp;gt;}[Total PO Spend (USD)] * Rebate5),&lt;BR /&gt;&lt;BR /&gt;If (Sum({&amp;lt;Year = {'$(=Max(Year)-1)'}&amp;gt;} [Total PO Spend (USD)] &amp;gt; [Spend Threshold5] and [Total PO Spend (USD)] &amp;lt;= [Spend Threshold6]), Sum({&amp;lt;Month={'Jan'}&amp;gt;}[Total PO Spend (USD)] * Rebate6),&lt;/P&gt;
&lt;P&gt;))))))))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not sure if there is a simpler way to do this, or if I just need to include something else.&lt;/P&gt;
&lt;P&gt;Thank you for your help!&lt;/P&gt;</description>
    <pubDate>Thu, 03 Nov 2022 15:36:05 GMT</pubDate>
    <dc:creator>tha5002</dc:creator>
    <dc:date>2022-11-03T15:36:05Z</dc:date>
    <item>
      <title>Multiple Supplier Rebate Thresholds</title>
      <link>https://community.qlik.com/t5/App-Development/Multiple-Supplier-Rebate-Thresholds/m-p/2000241#M82840</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;
&lt;P&gt;New job and new to qlik sense! I was given a project to become familiar with qlik, and have run into some knowledge/experience roadblocks. I would really appreciate any help that can be provided.&lt;/P&gt;
&lt;P&gt;I am trying to create an app that will provide information related to supplier spend, and the rebate we expect to receive based on thresholds.&lt;/P&gt;
&lt;P&gt;Similar to&amp;nbsp;&lt;A href="https://community.qlik.com/t5/QlikView-App-Dev/Help-With-Complex-quot-If-ElseIF-ElseIF-quot-Statement/td-p/1320032" target="_blank" rel="noopener"&gt;https://community.qlik.com/t5/QlikView-App-Dev/Help-With-Complex-quot-If-ElseIF-ElseIF-quot-Statement/td-p/1320032&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;I believe there are more complexities required for my app. I will try to give as much context as possible.&lt;/P&gt;
&lt;P&gt;In order to accommodate changing agreements with suppliers, the thresholds and rebate % will be maintained in an excel document that will be loaded as needed.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2022-11-03 101542.png" style="width: 999px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/92821iC5FDC3984D0C2036/image-size/large?v=v2&amp;amp;px=999" role="button" title="Screenshot 2022-11-03 101542.png" alt="Screenshot 2022-11-03 101542.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;As you can see from the sample screenshot, there are different rebate collection periods, and rebate types.&lt;/P&gt;
&lt;P&gt;For the time being I am most concerned with 'Quarterly' and 'Yearly' Rebate Collection Period, and the 'Threshold' Rebate Type.&lt;/P&gt;
&lt;P&gt;Quarterly = The threshold is calculated based on the total amount of PREVIOUS YEAR SPEND. (Rebate paid quarterly)&lt;/P&gt;
&lt;P&gt;Example: Supplier 4 spent $12,000,000 in 2021, effective rebate for any 2022 spend should be 5%&lt;/P&gt;
&lt;P&gt;If ([Rebate Collection Period] = 'Quarterly', Sum({&amp;lt;Year= {'$(=Max(Year)-1)'}&amp;gt;} [Total PO Spend (USD)])) -- Used this to check PY&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yearly = The threshold is calculated based on the total amount YEAR TO DATE (Rebate paid at end of year)&lt;/P&gt;
&lt;P&gt;Example: As spend increases throughout the year, the rebate should reflect this.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If ([Rebate Collection Period] = 'Yearly', Sum({&amp;lt;Year= {'$(=Max(Year))'}&amp;gt;} [Total PO Spend (USD)])) -- Used this to check YTD&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Yearly (Mar - Feb) etc... will be for suppliers that use a different fiscal year. I will tackle that after this portion works...&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;A user will select the 'reporting year' (e.g. 2022), and the output should display rebate values for monthly, quarterly, total. Image below.&lt;/P&gt;
&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="Screenshot 2022-11-03 111345.png" style="width: 459px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/92832i47A024D7206A72C3/image-dimensions/459x278?v=v2" width="459" height="278" role="button" title="Screenshot 2022-11-03 111345.png" alt="Screenshot 2022-11-03 111345.png" /&gt;&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I used the following expression to try and find the correct rebate. I believe that it is only choosing the lowest rebate threshold, and not going through the entire statement, as Supplier 4 in above image should be a higher tier.&lt;/P&gt;
&lt;P&gt;IF ([Rebate Collection Period] = 'Yearly',&lt;/P&gt;
&lt;P&gt;If(Sum({&amp;lt;Year = {'$(=Max(Year))'}&amp;gt;} [Total PO Spend (USD)] &amp;gt;= 1 and [Total PO Spend (USD)] &amp;lt;= [Spend Threshold]), Sum({&amp;lt;Month={'Jan'}&amp;gt;}[Total PO Spend (USD)] * Rebate),&lt;BR /&gt;&lt;BR /&gt;If(Sum({&amp;lt;Year = {'$(=Max(Year))'}&amp;gt;} [Total PO Spend (USD)] &amp;gt; [Spend Threshold] and [Total PO Spend (USD)] &amp;lt;= [Spend Threshold2]), Sum({&amp;lt;Month={'Jan'}&amp;gt;}[Total PO Spend (USD)] * Rebate2),&lt;BR /&gt;&lt;BR /&gt;If(Sum({&amp;lt;Year = {'$(=Max(Year))'}&amp;gt;} [Total PO Spend (USD)] &amp;gt; [Spend Threshold2] and [Total PO Spend (USD)] &amp;lt;= [Spend Threshold3]), Sum({&amp;lt;Month={'Jan'}&amp;gt;}[Total PO Spend (USD)] * Rebate3),&lt;BR /&gt;&lt;BR /&gt;If(Sum({&amp;lt;Year = {'$(=Max(Year))'}&amp;gt;} [Total PO Spend (USD)] &amp;gt; [Spend Threshold3] and [Total PO Spend (USD)] &amp;lt;= [Spend Threshold4]), Sum({&amp;lt;Month={'Jan'}&amp;gt;}[Total PO Spend (USD)] * Rebate4),&lt;BR /&gt;&lt;BR /&gt;If(Sum({&amp;lt;Year = {'$(=Max(Year))'}&amp;gt;} [Total PO Spend (USD)] &amp;gt; [Spend Threshold4] and [Total PO Spend (USD)] &amp;lt;= [Spend Threshold5]), Sum({&amp;lt;Month={'Jan'}&amp;gt;}[Total PO Spend (USD)] * Rebate5),&lt;BR /&gt;&lt;BR /&gt;If(Sum({&amp;lt;Year = {'$(=Max(Year))'}&amp;gt;} [Total PO Spend (USD)] &amp;gt; [Spend Threshold5] and [Total PO Spend (USD)] &amp;lt;= [Spend Threshold6]), Sum({&amp;lt;Month={'Jan'}&amp;gt;}[Total PO Spend (USD)] * Rebate6),&lt;/P&gt;
&lt;P&gt;)))))),&lt;/P&gt;
&lt;P&gt;If ([Rebate Collection Period] = 'Quarterly',&lt;/P&gt;
&lt;P&gt;If (Sum({&amp;lt;Year = {'$(=Max(Year)-1)'}&amp;gt;} [Total PO Spend (USD)] &amp;gt;= 1 and [Total PO Spend (USD)] &amp;lt;= [Spend Threshold]), Sum({&amp;lt;Month={'Jan'}&amp;gt;}[Total PO Spend (USD)] * Rebate),&lt;BR /&gt;&lt;BR /&gt;If (Sum({&amp;lt;Year = {'$(=Max(Year)-1)'}&amp;gt;} [Total PO Spend (USD)] &amp;gt; [Spend Threshold] and [Total PO Spend (USD)] &amp;lt;= [Spend Threshold2]), Sum({&amp;lt;Month={'Jan'}&amp;gt;}[Total PO Spend (USD)] * Rebate2),&lt;BR /&gt;&lt;BR /&gt;If (Sum({&amp;lt;Year = {'$(=Max(Year)-1)'}&amp;gt;} [Total PO Spend (USD)] &amp;gt; [Spend Threshold2] and [Total PO Spend (USD)] &amp;lt;= [Spend Threshold3]), Sum({&amp;lt;Month={'Jan'}&amp;gt;}[Total PO Spend (USD)] * Rebate3),&lt;BR /&gt;&lt;BR /&gt;If (Sum({&amp;lt;Year = {'$(=Max(Year)-1)'}&amp;gt;} [Total PO Spend (USD)] &amp;gt; [Spend Threshold3] and [Total PO Spend (USD)] &amp;lt;= [Spend Threshold4]), Sum({&amp;lt;Month={'Jan'}&amp;gt;}[Total PO Spend (USD)] * Rebate4),&lt;BR /&gt;&lt;BR /&gt;If (Sum({&amp;lt;Year = {'$(=Max(Year)-1)'}&amp;gt;} [Total PO Spend (USD)] &amp;gt; [Spend Threshold4] and [Total PO Spend (USD)] &amp;lt;= [Spend Threshold5]), Sum({&amp;lt;Month={'Jan'}&amp;gt;}[Total PO Spend (USD)] * Rebate5),&lt;BR /&gt;&lt;BR /&gt;If (Sum({&amp;lt;Year = {'$(=Max(Year)-1)'}&amp;gt;} [Total PO Spend (USD)] &amp;gt; [Spend Threshold5] and [Total PO Spend (USD)] &amp;lt;= [Spend Threshold6]), Sum({&amp;lt;Month={'Jan'}&amp;gt;}[Total PO Spend (USD)] * Rebate6),&lt;/P&gt;
&lt;P&gt;))))))))&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I am not sure if there is a simpler way to do this, or if I just need to include something else.&lt;/P&gt;
&lt;P&gt;Thank you for your help!&lt;/P&gt;</description>
      <pubDate>Thu, 03 Nov 2022 15:36:05 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Multiple-Supplier-Rebate-Thresholds/m-p/2000241#M82840</guid>
      <dc:creator>tha5002</dc:creator>
      <dc:date>2022-11-03T15:36:05Z</dc:date>
    </item>
  </channel>
</rss>

