<?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 Counting days in a row in a table based on threshold? in App Development</title>
    <link>https://community.qlik.com/t5/App-Development/Counting-days-in-a-row-in-a-table-based-on-threshold/m-p/1543238#M39178</link>
    <description>&lt;P&gt;Hi hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am wanting to display the number of consecutive days in a table when a KPI has passed a certain threshold.&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;Count # of days when KPI value is &amp;gt;=10&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 446px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/5797iE1FFDC6D2765241E/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Therefore, on 2019-01-04, the KPI was &amp;gt;=10 for 2 days in a row.&lt;/P&gt;&lt;P&gt;On 2019-01-15, the KPI was &amp;gt;=10 for 6 days in a row,&amp;nbsp; 7 the next day, etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried putting in a 0 | 1 flag for this in the load script and doing things with rangesum()&lt;/P&gt;&lt;P&gt;ex:&amp;nbsp;&lt;/P&gt;&lt;P&gt;rangesum(above(sum(KPI_flag),0,&amp;nbsp;if(above(sum(KPI_flag)) &amp;lt;&amp;gt; sum(KPI_flag),1,rowno())&amp;nbsp;))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it is not getting me where I want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Load Script I used:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[Original]:&lt;BR /&gt;load * INLINE [ pst, KPI&lt;BR /&gt;2019-01-01, 1&lt;BR /&gt;2019-01-02, 1&lt;BR /&gt;2019-01-03, 12&lt;BR /&gt;2019-01-04, 20&lt;BR /&gt;2019-01-05, 11&lt;BR /&gt;2019-01-06, 2&lt;BR /&gt;2019-01-07, 90&lt;BR /&gt;2019-01-08, 50&lt;BR /&gt;2019-01-09, 1&lt;BR /&gt;2019-01-10, 20&lt;BR /&gt;2019-01-11, 21&lt;BR /&gt;2019-01-12, 22&lt;BR /&gt;2019-01-13, 23&lt;BR /&gt;2019-01-14, 24&lt;BR /&gt;2019-01-15, 25&lt;BR /&gt;2019-01-16, 27&lt;BR /&gt;2019-01-17, 0&lt;BR /&gt;2019-01-17, 9&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;[Final]:&lt;BR /&gt;NoConcatenate Load pst, KPI,&lt;BR /&gt;if(KPI &amp;gt;=10, 1, 0) as KPI_flag&lt;BR /&gt;Resident [Original];&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;drop table [Original];&lt;BR /&gt;exit script;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have you guys done anything like this before?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;S&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 12 Feb 2019 19:49:27 GMT</pubDate>
    <dc:creator>Sazabi</dc:creator>
    <dc:date>2019-02-12T19:49:27Z</dc:date>
    <item>
      <title>Counting days in a row in a table based on threshold?</title>
      <link>https://community.qlik.com/t5/App-Development/Counting-days-in-a-row-in-a-table-based-on-threshold/m-p/1543238#M39178</link>
      <description>&lt;P&gt;Hi hello&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am wanting to display the number of consecutive days in a table when a KPI has passed a certain threshold.&lt;/P&gt;&lt;P&gt;Example:&lt;/P&gt;&lt;P&gt;Count # of days when KPI value is &amp;gt;=10&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 446px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/5797iE1FFDC6D2765241E/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Therefore, on 2019-01-04, the KPI was &amp;gt;=10 for 2 days in a row.&lt;/P&gt;&lt;P&gt;On 2019-01-15, the KPI was &amp;gt;=10 for 6 days in a row,&amp;nbsp; 7 the next day, etc.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried putting in a 0 | 1 flag for this in the load script and doing things with rangesum()&lt;/P&gt;&lt;P&gt;ex:&amp;nbsp;&lt;/P&gt;&lt;P&gt;rangesum(above(sum(KPI_flag),0,&amp;nbsp;if(above(sum(KPI_flag)) &amp;lt;&amp;gt; sum(KPI_flag),1,rowno())&amp;nbsp;))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But it is not getting me where I want.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Load Script I used:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;[Original]:&lt;BR /&gt;load * INLINE [ pst, KPI&lt;BR /&gt;2019-01-01, 1&lt;BR /&gt;2019-01-02, 1&lt;BR /&gt;2019-01-03, 12&lt;BR /&gt;2019-01-04, 20&lt;BR /&gt;2019-01-05, 11&lt;BR /&gt;2019-01-06, 2&lt;BR /&gt;2019-01-07, 90&lt;BR /&gt;2019-01-08, 50&lt;BR /&gt;2019-01-09, 1&lt;BR /&gt;2019-01-10, 20&lt;BR /&gt;2019-01-11, 21&lt;BR /&gt;2019-01-12, 22&lt;BR /&gt;2019-01-13, 23&lt;BR /&gt;2019-01-14, 24&lt;BR /&gt;2019-01-15, 25&lt;BR /&gt;2019-01-16, 27&lt;BR /&gt;2019-01-17, 0&lt;BR /&gt;2019-01-17, 9&lt;BR /&gt;];&lt;/P&gt;&lt;P&gt;[Final]:&lt;BR /&gt;NoConcatenate Load pst, KPI,&lt;BR /&gt;if(KPI &amp;gt;=10, 1, 0) as KPI_flag&lt;BR /&gt;Resident [Original];&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;drop table [Original];&lt;BR /&gt;exit script;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Have you guys done anything like this before?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;S&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 19:49:27 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Counting-days-in-a-row-in-a-table-based-on-threshold/m-p/1543238#M39178</guid>
      <dc:creator>Sazabi</dc:creator>
      <dc:date>2019-02-12T19:49:27Z</dc:date>
    </item>
    <item>
      <title>Re: Counting days in a row in a table based on threshold?</title>
      <link>https://community.qlik.com/t5/App-Development/Counting-days-in-a-row-in-a-table-based-on-threshold/m-p/1543280#M39181</link>
      <description>&lt;P&gt;Try this script.&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;[Original]:
load * ,if(KPI &amp;gt;=10, peek('KPI_flag')+1, 0) as KPI_flag 
INLINE [ 
pst, KPI
2019-01-01, 1
2019-01-02, 1
2019-01-03, 12
2019-01-04, 20
2019-01-05, 11
2019-01-06, 2
2019-01-07, 90
2019-01-08, 50
2019-01-09, 1
2019-01-10, 20
2019-01-11, 21
2019-01-12, 22
2019-01-13, 23
2019-01-14, 24
2019-01-15, 25
2019-01-16, 27
2019-01-17, 0
2019-01-17, 9
];&lt;/PRE&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="image.png" style="width: 976px;"&gt;&lt;img src="https://community.qlik.com/t5/image/serverpage/image-id/5807iB80D70AD2873A1F3/image-size/large?v=v2&amp;amp;px=999" role="button" title="image.png" alt="image.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 21:59:14 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Counting-days-in-a-row-in-a-table-based-on-threshold/m-p/1543280#M39181</guid>
      <dc:creator>Vegar</dc:creator>
      <dc:date>2019-02-12T21:59:14Z</dc:date>
    </item>
    <item>
      <title>Re: Counting days in a row in a table based on threshold?</title>
      <link>https://community.qlik.com/t5/App-Development/Counting-days-in-a-row-in-a-table-based-on-threshold/m-p/1543289#M39183</link>
      <description>&lt;P&gt;Hi Vegar,&amp;nbsp;&lt;/P&gt;&lt;P&gt;Very cool solution &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;&lt;P&gt;Now to take it to the next level:&lt;/P&gt;&lt;P&gt;Is there a way to do this calculation live on the front-end rather than hard-code the values into the data model?&lt;/P&gt;&lt;P&gt;In the case of having the timestamps broken out by dimensions, I can see we could sort by time and dimension and then include in the if-statement to check if the previous record is the same object and do the count.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thoughts?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;S&lt;/P&gt;</description>
      <pubDate>Tue, 12 Feb 2019 22:36:24 GMT</pubDate>
      <guid>https://community.qlik.com/t5/App-Development/Counting-days-in-a-row-in-a-table-based-on-threshold/m-p/1543289#M39183</guid>
      <dc:creator>Sazabi</dc:creator>
      <dc:date>2019-02-12T22:36:24Z</dc:date>
    </item>
  </channel>
</rss>

